Class: ManageIQ::ApplianceConsole::Cli
- Inherits:
-
Object
- Object
- ManageIQ::ApplianceConsole::Cli
- Defined in:
- lib/manageiq/appliance_console/cli.rb
Constant Summary collapse
- DB_OPT_KEYS =
%i[dbname username password hostname port local_file].freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #certs? ⇒ Boolean
- #config_container_pull_image ⇒ Object
- #config_container_registry ⇒ Object
- #config_containers_disk ⇒ Object
- #config_log_disk ⇒ Object
- #config_tmp_disk ⇒ Object
- #container_pull_image? ⇒ Boolean
- #container_registry? ⇒ Boolean
- #containers_disk? ⇒ Boolean
- #create_key ⇒ Object
- #database? ⇒ Boolean
- #database_admin? ⇒ Boolean
- #db_backup ⇒ Object
- #db_backup? ⇒ Boolean
- #db_dump ⇒ Object
- #db_dump? ⇒ Boolean
- #db_restore ⇒ Object
- #db_restore? ⇒ Boolean
- #disk ⇒ Object
- #disk_by_path(path) ⇒ Object
- #disk_from_string(path) ⇒ Object
- #extauth_opts ⇒ Object
- #extauth_opts? ⇒ Boolean
- #extract_db_opts(options) ⇒ Object
-
#host ⇒ Object
machine host.
-
#hostname ⇒ Object
database hostname.
-
#initialize(options = {}) ⇒ Cli
constructor
A new instance of Cli.
- #install_certs ⇒ Object
- #install_ipa ⇒ Object
- #install_ipa? ⇒ Boolean
- #key? ⇒ Boolean
- #key_configuration ⇒ Object
- #local?(name = hostname) ⇒ Boolean
- #local_database? ⇒ Boolean
- #log_disk? ⇒ Boolean
- #message_client_config ⇒ Object
- #message_client_config? ⇒ Boolean
- #message_client_unconfig ⇒ Object
- #message_client_unconfig? ⇒ Boolean
- #message_server_config ⇒ Object
- #message_server_config? ⇒ Boolean
- #message_server_unconfig ⇒ Object
- #message_server_unconfig? ⇒ Boolean
- #multiple_message_subcommands? ⇒ Boolean
- #oidc_config ⇒ Object
- #oidc_config? ⇒ Boolean
- #oidc_unconfig ⇒ Object
- #oidc_unconfig? ⇒ Boolean
- #openscap ⇒ Object
- #openscap? ⇒ Boolean
- #parse(args) ⇒ Object
- #password? ⇒ Boolean
- #region_number_required? ⇒ Boolean
- #replication_params? ⇒ Boolean
- #report_disk_error(missing_disk) ⇒ Object
- #run ⇒ Object
- #saml_config ⇒ Object
- #saml_config? ⇒ Boolean
- #saml_unconfig ⇒ Object
- #saml_unconfig? ⇒ Boolean
- #set_db ⇒ Object
- #set_external_db ⇒ Object
- #set_host? ⇒ Boolean
- #set_internal_db ⇒ Object
- #set_replication ⇒ Object
- #set_replication? ⇒ Boolean
- #set_server_state ⇒ Object
- #set_server_state? ⇒ Boolean
- #tmp_disk? ⇒ Boolean
- #uninstall_ipa ⇒ Object
- #uninstall_ipa? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Cli
Returns a new instance of Cli.
148 149 150 |
# File 'lib/manageiq/appliance_console/cli.rb', line 148 def initialize( = {}) self. = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
16 17 18 |
# File 'lib/manageiq/appliance_console/cli.rb', line 16 def @options end |
Class Method Details
.parse(args) ⇒ Object
585 586 587 |
# File 'lib/manageiq/appliance_console/cli.rb', line 585 def self.parse(args) new.parse(args).run end |
Instance Method Details
#certs? ⇒ Boolean
64 65 66 |
# File 'lib/manageiq/appliance_console/cli.rb', line 64 def certs? [:http_cert] end |
#config_container_pull_image ⇒ Object
514 515 516 517 |
# File 'lib/manageiq/appliance_console/cli.rb', line 514 def config_container_pull_image container_image = [:container_pull_image] ManageIQ::ApplianceConsole::ContainersConfiguration.new(:container_image => container_image).activate if container_image end |
#config_container_registry ⇒ Object
502 503 504 505 506 507 508 509 510 511 512 |
# File 'lib/manageiq/appliance_console/cli.rb', line 502 def config_container_registry if [:container_registry_uri] ManageIQ::ApplianceConsole::ContainersConfiguration.new( :container_registry_uri => [:container_registry_uri], :container_registry_username => [:container_registry_username], :container_registry_password => [:container_registry_password], :container_registry_authfile => [:container_registry_authfile], :container_registry_tls_verify => [:container_registry_tls_verify] ).activate end end |
#config_containers_disk ⇒ Object
492 493 494 495 496 497 498 499 500 |
# File 'lib/manageiq/appliance_console/cli.rb', line 492 def config_containers_disk containers_disk = disk_from_string([:containers_storage_disk]) if containers_disk say("creating containers storage disk") ManageIQ::ApplianceConsole::ContainersConfiguration.new(:disk => containers_disk).activate else report_disk_error([:containers_storage_disk]) end end |
#config_log_disk ⇒ Object
482 483 484 485 486 487 488 489 490 |
# File 'lib/manageiq/appliance_console/cli.rb', line 482 def config_log_disk if (log_disk = disk_from_string([:logdisk])) say "creating log disk" config = ManageIQ::ApplianceConsole::LogfileConfiguration.new(:disk => log_disk) config.activate else report_disk_error([:logdisk]) end end |
#config_tmp_disk ⇒ Object
472 473 474 475 476 477 478 479 480 |
# File 'lib/manageiq/appliance_console/cli.rb', line 472 def config_tmp_disk if (tmp_disk = disk_from_string([:tmpdisk])) say "creating temp disk" config = ManageIQ::ApplianceConsole::TempStorageConfiguration.new(:disk => tmp_disk) config.activate else report_disk_error([:tmpdisk]) end end |
#container_pull_image? ⇒ Boolean
92 93 94 |
# File 'lib/manageiq/appliance_console/cli.rb', line 92 def container_pull_image? [:container_pull_image] end |
#container_registry? ⇒ Boolean
88 89 90 |
# File 'lib/manageiq/appliance_console/cli.rb', line 88 def container_registry? [:container_registry_uri] end |
#containers_disk? ⇒ Boolean
84 85 86 |
# File 'lib/manageiq/appliance_console/cli.rb', line 84 def containers_disk? [:containers_storage_disk] end |
#create_key ⇒ Object
422 423 424 425 426 427 428 |
# File 'lib/manageiq/appliance_console/cli.rb', line 422 def create_key say "#{key_configuration.action} encryption key" unless key_configuration.activate say("Could not create encryption key (v2_key)") exit(1) end end |
#database? ⇒ Boolean
40 41 42 |
# File 'lib/manageiq/appliance_console/cli.rb', line 40 def database? ([:standalone] || hostname) && !database_admin? end |
#database_admin? ⇒ Boolean
44 45 46 |
# File 'lib/manageiq/appliance_console/cli.rb', line 44 def database_admin? db_dump? || db_backup? || db_restore? end |
#db_backup ⇒ Object
389 390 391 |
# File 'lib/manageiq/appliance_console/cli.rb', line 389 def db_backup PostgresAdmin.backup(extract_db_opts()) end |
#db_backup? ⇒ Boolean
52 53 54 |
# File 'lib/manageiq/appliance_console/cli.rb', line 52 def db_backup? [:backup] end |
#db_dump ⇒ Object
385 386 387 |
# File 'lib/manageiq/appliance_console/cli.rb', line 385 def db_dump PostgresAdmin.backup_pg_dump(extract_db_opts()) end |
#db_dump? ⇒ Boolean
48 49 50 |
# File 'lib/manageiq/appliance_console/cli.rb', line 48 def db_dump? [:dump] end |
#db_restore ⇒ Object
393 394 395 |
# File 'lib/manageiq/appliance_console/cli.rb', line 393 def db_restore PostgresAdmin.restore(extract_db_opts()) end |
#db_restore? ⇒ Boolean
56 57 58 |
# File 'lib/manageiq/appliance_console/cli.rb', line 56 def db_restore? [:restore] end |
#disk ⇒ Object
157 158 159 |
# File 'lib/manageiq/appliance_console/cli.rb', line 157 def disk LinuxAdmin::Disk.local.detect { |d| d.partitions.empty? } end |
#disk_by_path(path) ⇒ Object
161 162 163 |
# File 'lib/manageiq/appliance_console/cli.rb', line 161 def disk_by_path(path) LinuxAdmin::Disk.local.detect { |d| d.path == path } end |
#disk_from_string(path) ⇒ Object
152 153 154 155 |
# File 'lib/manageiq/appliance_console/cli.rb', line 152 def disk_from_string(path) return if path.blank? path == "auto" ? disk : disk_by_path(path) end |
#extauth_opts ⇒ Object
529 530 531 532 533 534 |
# File 'lib/manageiq/appliance_console/cli.rb', line 529 def extauth_opts extauthopts = ExternalAuthOptions.new extauthopts_hash = extauthopts.parse([:extauth_opts]) raise "Must specify at least one external authentication option to set" unless extauthopts_hash.present? extauthopts.update_configuration(extauthopts_hash) end |
#extauth_opts? ⇒ Boolean
96 97 98 |
# File 'lib/manageiq/appliance_console/cli.rb', line 96 def extauth_opts? [:extauth_opts] end |
#extract_db_opts(options) ⇒ Object
398 399 400 401 402 403 404 405 406 407 408 409 410 |
# File 'lib/manageiq/appliance_console/cli.rb', line 398 def extract_db_opts() require 'manageiq/appliance_console/postgres_admin' db_opts = {} DB_OPT_KEYS.each { |k| db_opts[k] = [k] if [k] } if db_dump? && [:exclude_table_data] db_opts[:exclude_table_data] = [:exclude_table_data] end db_opts end |
#host ⇒ Object
machine host
19 20 21 |
# File 'lib/manageiq/appliance_console/cli.rb', line 19 def host [:host] || LinuxAdmin::Hosts.new.hostname end |
#hostname ⇒ Object
database hostname
24 25 26 |
# File 'lib/manageiq/appliance_console/cli.rb', line 24 def hostname [:internal] ? "localhost" : [:hostname] end |
#install_certs ⇒ Object
430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/manageiq/appliance_console/cli.rb', line 430 def install_certs say "creating ssl certificates" config = CertificateAuthority.new( :hostname => host, :realm => [:iparealm], :ca_name => [:ca], :http => [:http_cert], :verbose => [:verbose], ) config.activate say "\ncertificate result: #{config.status_string}" unless config.complete? say "After the certificates are retrieved, rerun to update service configuration files" end end |
#install_ipa ⇒ Object
447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'lib/manageiq/appliance_console/cli.rb', line 447 def install_ipa raise "please uninstall ipa before reinstalling" if ExternalHttpdAuthentication.ipa_client_configured? config = ExternalHttpdAuthentication.new( host, :ipaserver => [:ipaserver], :domain => [:ipadomain], :realm => [:iparealm], :principal => [:ipaprincipal], :password => [:ipapassword], ) config.post_activation if config.activate end |
#install_ipa? ⇒ Boolean
72 73 74 |
# File 'lib/manageiq/appliance_console/cli.rb', line 72 def install_ipa? [:ipaserver] end |
#key? ⇒ Boolean
36 37 38 |
# File 'lib/manageiq/appliance_console/cli.rb', line 36 def key? [:key] || [:fetch_key] || (local_database? && !key_configuration.key_exist?) end |
#key_configuration ⇒ Object
412 413 414 415 416 417 418 419 420 |
# File 'lib/manageiq/appliance_console/cli.rb', line 412 def key_configuration @key_configuration ||= KeyConfiguration.new( :action => [:fetch_key] ? :fetch : :create, :force => [:fetch_key] ? true : [:force_key], :host => [:fetch_key], :login => [:sshlogin], :password => [:sshpassword], ) end |
#local?(name = hostname) ⇒ Boolean
28 29 30 |
# File 'lib/manageiq/appliance_console/cli.rb', line 28 def local?(name = hostname) name.presence.in?(["localhost", "127.0.0.1", nil]) end |
#local_database? ⇒ Boolean
60 61 62 |
# File 'lib/manageiq/appliance_console/cli.rb', line 60 def local_database? database? && (local?(hostname) || [:standalone]) end |
#log_disk? ⇒ Boolean
80 81 82 |
# File 'lib/manageiq/appliance_console/cli.rb', line 80 def log_disk? [:logdisk] end |
#message_client_config ⇒ Object
562 563 564 565 566 |
# File 'lib/manageiq/appliance_console/cli.rb', line 562 def raise "Message Client Configuration is not available" unless MessageClientConfiguration.available? MessageClientConfiguration.new().configure end |
#message_client_config? ⇒ Boolean
116 117 118 |
# File 'lib/manageiq/appliance_console/cli.rb', line 116 def [:message_client_config] end |
#message_client_unconfig ⇒ Object
568 569 570 |
# File 'lib/manageiq/appliance_console/cli.rb', line 568 def MessageClientConfiguration.new().unconfigure end |
#message_client_unconfig? ⇒ Boolean
120 121 122 |
# File 'lib/manageiq/appliance_console/cli.rb', line 120 def [:message_client_unconfig] end |
#message_server_config ⇒ Object
552 553 554 555 556 |
# File 'lib/manageiq/appliance_console/cli.rb', line 552 def raise "Message Server Configuration is not available" unless MessageServerConfiguration.available? MessageServerConfiguration.new().configure end |
#message_server_config? ⇒ Boolean
108 109 110 |
# File 'lib/manageiq/appliance_console/cli.rb', line 108 def [:message_server_config] end |
#message_server_unconfig ⇒ Object
558 559 560 |
# File 'lib/manageiq/appliance_console/cli.rb', line 558 def MessageServerConfiguration.new().unconfigure end |
#message_server_unconfig? ⇒ Boolean
112 113 114 |
# File 'lib/manageiq/appliance_console/cli.rb', line 112 def [:message_server_unconfig] end |
#multiple_message_subcommands? ⇒ Boolean
250 251 252 253 |
# File 'lib/manageiq/appliance_console/cli.rb', line 250 def a = [[:message_server_config], [:message_server_unconfig], [:message_client_config], [:message_client_unconfig]] a.each_with_object(Hash.new(0)) { |o, h| h[o] += 1 }[true] > 1 end |
#oidc_config ⇒ Object
544 545 546 |
# File 'lib/manageiq/appliance_console/cli.rb', line 544 def oidc_config OIDCAuthentication.new().configure([:oidc_client_host] || host) end |
#oidc_config? ⇒ Boolean
124 125 126 |
# File 'lib/manageiq/appliance_console/cli.rb', line 124 def oidc_config? [:oidc_config] end |
#oidc_unconfig ⇒ Object
548 549 550 |
# File 'lib/manageiq/appliance_console/cli.rb', line 548 def oidc_unconfig OIDCAuthentication.new().unconfigure end |
#oidc_unconfig? ⇒ Boolean
128 129 130 |
# File 'lib/manageiq/appliance_console/cli.rb', line 128 def oidc_unconfig? [:oidc_unconfig] end |
#openscap ⇒ Object
467 468 469 470 |
# File 'lib/manageiq/appliance_console/cli.rb', line 467 def openscap say("Configuring Openscap") ManageIQ::ApplianceConsole::Scap.new.lockdown end |
#openscap? ⇒ Boolean
144 145 146 |
# File 'lib/manageiq/appliance_console/cli.rb', line 144 def openscap? [:openscap] end |
#parse(args) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/manageiq/appliance_console/cli.rb', line 165 def parse(args) args.shift if args.first == "--" # Handle when called through script/runner self. = Optimist.(args) do "Usage: appliance_console_cli [options]" opt :host, "/etc/hosts name", :type => :string, :short => 'H' opt :region, "Region Number", :type => :integer, :short => "r" opt :internal, "Internal Database", :short => 'i' opt :hostname, "Database Hostname", :type => :string, :short => 'h' opt :port, "Database Port", :type => :integer, :default => 5432 opt :username, "Database Username", :type => :string, :short => 'U', :default => "root" opt :password, "Database Password", :type => :string, :short => "p" opt :dbname, "Database Name", :type => :string, :short => "d", :default => "vmdb_production" opt :local_file, "Source/Destination file for DB dump/backup/restore", :type => :string, :shoft => "l" opt :dump, "Perform a pg-dump" opt :backup, "Perform a pg-basebackup" opt :restore, "Restore a database dump/backup" opt :standalone, "Run this server as a standalone database server", :type => :bool, :short => 'S' opt :key, "Create encryption key", :type => :boolean, :short => "k" opt :fetch_key, "SSH host with encryption key", :type => :string, :short => "K" opt :force_key, "Forcefully create encryption key", :type => :boolean, :short => "f" opt :sshlogin, "SSH login", :type => :string, :default => "root" opt :sshpassword, "SSH password", :type => :string opt :replication, "Configure database replication as primary or standby", :type => :string, :short => :none opt :primary_host, "Primary database host IP address", :type => :string, :short => :none opt :standby_host, "Standby database host IP address", :type => :string, :short => :none opt :auto_failover, "Configure Replication Manager (repmgrd) for automatic failover", :type => :bool, :short => :none opt :cluster_node_number, "Database unique cluster node number", :type => :integer, :short => :none opt :verbose, "Verbose", :type => :boolean, :short => "v" opt :dbdisk, "Database Disk Path", :type => :string opt :logdisk, "Log Disk Path", :type => :string opt :tmpdisk, "Temp storage Disk Path", :type => :string opt :uninstall_ipa, "Uninstall IPA Client", :type => :boolean, :default => false opt :ipaserver, "IPA Server FQDN", :type => :string opt :ipaprincipal, "IPA Server principal", :type => :string, :default => "admin" opt :ipapassword, "IPA Server password", :type => :string opt :ipadomain, "IPA Server domain (optional)", :type => :string opt :iparealm, "IPA Server realm (optional)", :type => :string opt :ca, "CA name used for certmonger", :type => :string, :default => "ipa" opt :http_cert, "install certs for http server", :type => :boolean opt :extauth_opts, "External Authentication Options", :type => :string opt :saml_config, "Configure Appliance for SAML Authentication", :type => :boolean, :default => false opt :saml_client_host, "Optional Appliance host used for SAML registration", :type => :string opt :saml_idp_metadata, "The file path or URL of the SAML IDP Metadata", :type => :string opt :saml_enable_sso, "Optionally enable SSO with SAML Authentication", :type => :boolean, :default => false opt :saml_unconfig, "Unconfigure Appliance SAML Authentication", :type => :boolean, :default => false opt :oidc_config, "Configure Appliance for OpenID-Connect Authentication", :type => :boolean, :default => false opt :oidc_url, "The OpenID-Connect Provider URL", :type => :string opt :oidc_client_host, "Optional Appliance host used for OpenID-Connect Authentication", :type => :string opt :oidc_client_id, "The OpenID-Connect Provider Client ID", :type => :string opt :oidc_client_secret, "The OpenID-Connect Provider Client Secret", :type => :string opt :oidc_insecure, "OpenID-Connect Insecure No SSL Verify (development)", :type => :boolean, :default => false opt :oidc_introspection_endpoint, "The OpenID-Connect Provider Introspect Endpoint", :type => :string opt :oidc_enable_sso, "Optionally enable SSO with OpenID-Connect Authentication", :type => :boolean, :default => false opt :oidc_unconfig, "Unconfigure Appliance OpenID-Connect Authentication", :type => :boolean, :default => false opt :server, "{start|stop|restart} actions on evmserverd Server", :type => :string opt :openscap, "Setup OpenScap", :type => :boolean, :default => false opt :message_server_config, "Subcommand to Configure Appliance as a Kafka Message Server", :type => :boolean, :default => false opt :message_server_unconfig, "Subcommand to Unconfigure Appliance as a Kafka Message Server", :type => :boolean, :default => false opt :message_client_config, "Subcommand to Configure Appliance as a Kafka Message Client", :type => :boolean, :default => false opt :message_client_unconfig, "Subcommand to Unconfigure Appliance as a Kafka Message Client", :type => :boolean, :default => false opt :message_keystore_username, "Message Server Keystore Username", :type => :string opt :message_keystore_password, "Message Server Keystore Password", :type => :string opt :message_server_username, "Message Server Username", :type => :string opt :message_server_password, "Message Server password", :type => :string opt :message_server_port, "Message Server Port", :type => :integer opt :message_server_use_ipaddr, "Deprecated: Message Server Use Address", :type => :boolean, :default => false opt :message_server_host, "Message Server Hostname or IP Address", :type => :string opt :message_truststore_path_src, "Message Server Truststore Path", :type => :string opt :message_ca_cert_path_src, "Message Server CA Cert Path", :type => :string opt :message_persistent_disk, "Message Persistent Disk Path", :type => :string opt :containers_storage_disk, "Containers Storage Disk Path", :type => :string opt :container_registry_uri, "Container Registry URI", :type => :string opt :container_registry_username, "Container Registry Username", :type => :string opt :container_registry_password, "Container Registry Password", :type => :string opt :container_registry_authfile, "Path of the authentication file for container registry auth", :type => :string opt :container_registry_tls_verify, "Verify certificates when contacting registries", :type => :boolean opt :container_pull_image, "Container Pull Image", :type => :string end Optimist.die :region, "needed when setting up a local database" if region_number_required? && [:region].nil? Optimist.die "Supply only one of --message-server-config, --message-server-unconfig, --message-client-config or --message-client-unconfig" if warn("--message_server_use_ipaddr is deprecated and will be ignored") if [:message_server_use_ipaddr] self end |
#password? ⇒ Boolean
324 325 326 |
# File 'lib/manageiq/appliance_console/cli.rb', line 324 def password? [:password] && ![:password].strip.empty? end |
#region_number_required? ⇒ Boolean
255 256 257 |
# File 'lib/manageiq/appliance_console/cli.rb', line 255 def region_number_required? ![:standalone] && local_database? && !database_admin? end |
#replication_params? ⇒ Boolean
140 141 142 |
# File 'lib/manageiq/appliance_console/cli.rb', line 140 def replication_params? [:replication] == "primary" || ([:replication] == "standby" && [:primary_host]) end |
#report_disk_error(missing_disk) ⇒ Object
519 520 521 522 523 524 525 526 527 |
# File 'lib/manageiq/appliance_console/cli.rb', line 519 def report_disk_error(missing_disk) choose_disk = disk.try(:path) if choose_disk say "could not find disk #{missing_disk}" say "if you pass auto, it will choose: #{choose_disk}" else say "no disks with a free partition" end end |
#run ⇒ Object
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
# File 'lib/manageiq/appliance_console/cli.rb', line 259 def run Optimist.educate unless set_host? || key? || database? || db_dump? || db_backup? || db_restore? || tmp_disk? || log_disk? || containers_disk? || container_registry? || container_pull_image? || uninstall_ipa? || install_ipa? || certs? || extauth_opts? || set_server_state? || set_replication? || openscap? || saml_config? || saml_unconfig? || oidc_config? || oidc_unconfig? || || || || if set_host? system_hosts = LinuxAdmin::Hosts.new system_hosts.hostname = [:host] system_hosts.set_loopback_hostname([:host]) system_hosts.save end create_key if key? set_db if database? set_replication if set_replication? db_dump if db_dump? db_backup if db_backup? db_restore if db_restore? config_tmp_disk if tmp_disk? config_log_disk if log_disk? config_containers_disk if containers_disk? config_container_registry if container_registry? config_container_pull_image if container_pull_image? uninstall_ipa if uninstall_ipa? install_ipa if install_ipa? install_certs if certs? extauth_opts if extauth_opts? saml_config if saml_config? saml_unconfig if saml_unconfig? oidc_config if oidc_config? oidc_unconfig if oidc_unconfig? openscap if openscap? if if if if # set_server_state must be after set_db and message_*_config so that a user # can configure database, messaging, and start the server in one command set_server_state if set_server_state? rescue CliError => e say(e.) say("") exit(1) rescue AwesomeSpawn::CommandResultError => e say e.result.output say e.result.error say "" raise end |
#saml_config ⇒ Object
536 537 538 |
# File 'lib/manageiq/appliance_console/cli.rb', line 536 def saml_config SamlAuthentication.new().configure([:saml_client_host] || host) end |
#saml_config? ⇒ Boolean
100 101 102 |
# File 'lib/manageiq/appliance_console/cli.rb', line 100 def saml_config? [:saml_config] end |
#saml_unconfig ⇒ Object
540 541 542 |
# File 'lib/manageiq/appliance_console/cli.rb', line 540 def saml_unconfig SamlAuthentication.new().unconfigure end |
#saml_unconfig? ⇒ Boolean
104 105 106 |
# File 'lib/manageiq/appliance_console/cli.rb', line 104 def saml_unconfig? [:saml_unconfig] end |
#set_db ⇒ Object
314 315 316 317 318 319 320 321 322 |
# File 'lib/manageiq/appliance_console/cli.rb', line 314 def set_db raise "No encryption key (v2_key) present" unless key_configuration.key_exist? raise "A password is required to configure a database" unless password? if local? set_internal_db else set_external_db end end |
#set_external_db ⇒ Object
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/manageiq/appliance_console/cli.rb', line 350 def set_external_db say "configuring external database" config = ManageIQ::ApplianceConsole::ExternalDatabaseConfiguration.new({ :host => [:hostname], :port => [:port], :database => [:dbname], :region => [:region], :username => [:username], :password => [:password], :interactive => false, }.delete_if { |_n, v| v.nil? }) # call create_or_join_region (depends on region value) raise CliError, "Failed to configure external database" unless config.activate end |
#set_host? ⇒ Boolean
32 33 34 |
# File 'lib/manageiq/appliance_console/cli.rb', line 32 def set_host? [:host] end |
#set_internal_db ⇒ Object
328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/manageiq/appliance_console/cli.rb', line 328 def set_internal_db say "configuring internal database" config = ManageIQ::ApplianceConsole::InternalDatabaseConfiguration.new({ :database => [:dbname], :region => [:region], :username => [:username], :password => [:password], :interactive => false, :disk => disk_from_string([:dbdisk]), :run_as_evm_server => ![:standalone] }.delete_if { |_n, v| v.nil? }) config.check_disk_is_mount_point # create partition, pv, vg, lv, ext4, update fstab, mount disk # initdb, relabel log directory for selinux, update configs, # start pg, create user, create db update the rails configuration, # verify, set up the database with region. activate does it all! raise CliError, "Failed to configure internal database" unless config.activate rescue RuntimeError => e raise CliError, "Failed to configure internal database #{e.}" end |
#set_replication ⇒ Object
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/manageiq/appliance_console/cli.rb', line 366 def set_replication if [:replication] == "primary" db_replication = ManageIQ::ApplianceConsole::DatabaseReplicationPrimary.new say("Configuring Server as Primary") else db_replication = ManageIQ::ApplianceConsole::DatabaseReplicationStandby.new say("Configuring Server as Standby") db_replication.disk = disk_from_string([:dbdisk]) db_replication.primary_host = [:primary_host] db_replication.standby_host = [:standby_host] if [:standby_host] db_replication.run_repmgrd_configuration = [:auto_failover] ? true : false end db_replication.database_name = [:dbname] if [:dbname] db_replication.database_user = [:username] if [:username] db_replication.node_number = [:cluster_node_number] db_replication.database_password = [:password] db_replication.activate end |
#set_replication? ⇒ Boolean
136 137 138 |
# File 'lib/manageiq/appliance_console/cli.rb', line 136 def set_replication? [:cluster_node_number] && [:password] && replication_params? end |
#set_server_state ⇒ Object
572 573 574 575 576 577 578 579 580 581 582 583 |
# File 'lib/manageiq/appliance_console/cli.rb', line 572 def set_server_state case [:server] when "start" EvmServer.start unless EvmServer.running? when "stop" EvmServer.stop if EvmServer.running? when "restart" EvmServer.restart else raise "Invalid server action" end end |
#set_server_state? ⇒ Boolean
132 133 134 |
# File 'lib/manageiq/appliance_console/cli.rb', line 132 def set_server_state? [:server] end |
#tmp_disk? ⇒ Boolean
76 77 78 |
# File 'lib/manageiq/appliance_console/cli.rb', line 76 def tmp_disk? [:tmpdisk] end |
#uninstall_ipa ⇒ Object
461 462 463 464 465 |
# File 'lib/manageiq/appliance_console/cli.rb', line 461 def uninstall_ipa say "Uninstalling IPA-client" config = ExternalHttpdAuthentication.new config.deactivate if config.ipa_client_configured? end |
#uninstall_ipa? ⇒ Boolean
68 69 70 |
# File 'lib/manageiq/appliance_console/cli.rb', line 68 def uninstall_ipa? [:uninstall_ipa] end |