Class: ManageIQ::ApplianceConsole::MessageClientConfiguration

Inherits:
MessageConfiguration show all
Defined in:
lib/manageiq/appliance_console/message_configuration_client.rb

Constant Summary

Constants inherited from MessageConfiguration

ManageIQ::ApplianceConsole::MessageConfiguration::BASE_DIR, ManageIQ::ApplianceConsole::MessageConfiguration::CONFIG_DIR, ManageIQ::ApplianceConsole::MessageConfiguration::LOGS_DIR, ManageIQ::ApplianceConsole::MessageConfiguration::MIQ_CONFIG_DIR, ManageIQ::ApplianceConsole::MessageConfiguration::SAMPLE_CONFIG_DIR

Instance Attribute Summary collapse

Attributes inherited from MessageConfiguration

#ca_cert_path, #client_properties_path, #config_dir_path, #keystore_dir_path, #keystore_path, #message_keystore_password, #message_keystore_username, #message_server_host, #message_server_port, #messaging_yaml_path, #messaging_yaml_sample_path, #miq_config_dir_path, #sample_config_dir_path, #truststore_path

Instance Method Summary collapse

Methods inherited from MessageConfiguration

#already_configured?, #ask_questions, #configure_messaging_type, #configure_messaging_yaml, #create_client_properties, #file_contains?, #file_found?, #files_found?, #host_reachable?, #remove_installed_files, #restart_evmserverd, #secure?, #secure_client_properties_content, #unconfigure, #unsecure_client_properties_content, #valid_environment?

Constructor Details

#initialize(options = {}) ⇒ MessageClientConfiguration

Returns a new instance of MessageClientConfiguration.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 13

def initialize(options = {})
  super(options)

  @message_server_host         = options[:message_server_host]
  @message_server_username     = options[:message_server_usernamed] || "root"
  @message_server_password     = options[:message_server_password]

  @message_truststore_path_src = options[:message_truststore_path_src] || truststore_path
  @message_ca_cert_path_src    = options[:message_ca_cert_path_src] || ca_cert_path

  @installed_files = [client_properties_path, messaging_yaml_path, truststore_path]
end

Instance Attribute Details

#installed_filesObject (readonly)

Returns the value of attribute installed_files.



10
11
12
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 10

def installed_files
  @installed_files
end

#message_ca_cert_path_srcObject (readonly)

Returns the value of attribute message_ca_cert_path_src.



10
11
12
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 10

def message_ca_cert_path_src
  @message_ca_cert_path_src
end

#message_server_passwordObject (readonly)

Returns the value of attribute message_server_password.



10
11
12
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 10

def message_server_password
  @message_server_password
end

#message_server_usernameObject (readonly)

Returns the value of attribute message_server_username.



10
11
12
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 10

def message_server_username
  @message_server_username
end

#message_truststore_path_srcObject (readonly)

Returns the value of attribute message_truststore_path_src.



10
11
12
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 10

def message_truststore_path_src
  @message_truststore_path_src
end

Instance Method Details

#ask_for_parametersObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 47

def ask_for_parameters
  say("\nMessage Client Parameters:\n\n")

  @message_server_host         = ask_for_string("Message Server Hostname or IP address")
  @message_server_port         = ask_for_integer("Message Server Port number", (1..65_535), 9_093).to_i
  @message_server_username     = ask_for_string("Message Server Username", message_server_username)
  @message_server_password     = ask_for_password("Message Server Password")
  @message_truststore_path_src = ask_for_string("Message Server Truststore Path", truststore_path)
  @message_ca_cert_path_src    = ask_for_string("Message Server CA Cert Path", ca_cert_path)
  @message_keystore_username   = ask_for_string("Message Keystore Username", message_keystore_username) if secure?
  @message_keystore_password   = ask_for_password("Message Keystore Password") if secure?
end

#configureObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 26

def configure
  begin
    MessageServerConfiguration.new.unconfigure if MessageServerConfiguration.configured?
    configure_messaging_yaml          # Set up the local message client in case EVM is actually running on this, Message Server
    create_client_properties          # Create the client.properties configuration fle
    fetch_truststore_from_server      # Fetch the Java Keystore from the Kafka Server
    configure_messaging_type("kafka") # Settings.prototype.messaging_type = 'kafka'
    restart_evmserverd
  rescue AwesomeSpawn::CommandResultError => e
    say(e.result.output)
    say(e.result.error)
    say("")
    say("Failed to Configure the Message Client- #{e}")
    return false
  rescue => e
    say("Failed to Configure the Message Client- #{e}")
    return false
  end
  true
end

#fetch_ca_cert_from_serverObject



74
75
76
77
78
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 74

def fetch_ca_cert_from_server
  say(__method__.to_s.tr("_", " ").titleize)

  fetch_from_server(message_ca_cert_path_src, ca_cert_path)
end

#fetch_truststore_from_serverObject



68
69
70
71
72
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 68

def fetch_truststore_from_server
  say(__method__.to_s.tr("_", " ").titleize)

  fetch_from_server(message_truststore_path_src, truststore_path)
end

#show_parametersObject



60
61
62
63
64
65
66
# File 'lib/manageiq/appliance_console/message_configuration_client.rb', line 60

def show_parameters
  say("\nMessage Client Configuration:\n")
  say("Message Client Details:\n")
  say("  Message Server Hostname:   #{message_server_host}\n")
  say("  Message Server Username:   #{message_server_username}\n")
  say("  Message Keystore Username: #{message_keystore_username}\n")
end