Class: ManageIQ::ApplianceConsole::CertificateAuthority
- Inherits:
-
Object
- Object
- ManageIQ::ApplianceConsole::CertificateAuthority
- Defined in:
- lib/manageiq/appliance_console/certificate_authority.rb
Constant Summary collapse
- CFME_DIR =
"/var/www/miq/vmdb/certs"
Instance Attribute Summary collapse
-
#ca_name ⇒ Object
name of certificate authority.
-
#hostname ⇒ Object
hostname of current machine.
-
#http ⇒ Object
true if we should configure http endpoint.
-
#realm ⇒ Object
Returns the value of attribute realm.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #activate ⇒ Object
- #ask_questions ⇒ Object
- #complete? ⇒ Boolean
- #configure_http ⇒ Object
-
#initialize(options = {}) ⇒ CertificateAuthority
constructor
A new instance of CertificateAuthority.
- #ipa? ⇒ Boolean
- #status ⇒ Object
- #status_string ⇒ Object
- #valid_environment? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ CertificateAuthority
Returns a new instance of CertificateAuthority.
19 20 21 22 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 19 def initialize( = {}) .each { |n, v| public_send("#{n}=", v) } @ca_name ||= "ipa" end |
Instance Attribute Details
#ca_name ⇒ Object
name of certificate authority
14 15 16 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 14 def ca_name @ca_name end |
#hostname ⇒ Object
hostname of current machine
11 12 13 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 11 def hostname @hostname end |
#http ⇒ Object
true if we should configure http endpoint
16 17 18 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 16 def http @http end |
#realm ⇒ Object
Returns the value of attribute realm.
12 13 14 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 12 def realm @realm end |
#verbose ⇒ Object
Returns the value of attribute verbose.
17 18 19 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 17 def verbose @verbose end |
Instance Method Details
#activate ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 33 def activate valid_environment? configure_http if http status_string end |
#ask_questions ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 24 def ask_questions if ipa? self.principal = just_ask("IPA Server Principal", @principal) self.password = ask_for_password("IPA Server Principal Password", @password) end self.http = ask_yn("Configure certificate for http server", "Y") true end |
#complete? ⇒ Boolean
77 78 79 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 77 def complete? !status.values.detect { |v| v != ManageIQ::ApplianceConsole::Certificate::STATUS_COMPLETE } end |
#configure_http ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 49 def configure_http cert = Certificate.new( :key_filename => "#{CFME_DIR}/server.cer.key", :cert_filename => "#{CFME_DIR}/server.cer", :root_filename => "#{CFME_DIR}/root.crt", :service => "HTTP", :extensions => %w(server), :ca_name => ca_name, :hostname => hostname, :owner => "apache.apache", ).request if cert.complete? say "configuring apache to use new certs" LinuxAdmin::Service.new("httpd").restart cert.enable_certmonger end self.http = cert.status end |
#ipa? ⇒ Boolean
81 82 83 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 81 def ipa? ca_name == "ipa" end |
#status ⇒ Object
69 70 71 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 69 def status {"http" => http}.delete_if { |_n, v| !v } end |
#status_string ⇒ Object
73 74 75 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 73 def status_string status.collect { |n, v| "#{n}: #{v}" }.join " " end |
#valid_environment? ⇒ Boolean
41 42 43 44 45 46 47 |
# File 'lib/manageiq/appliance_console/certificate_authority.rb', line 41 def valid_environment? if ipa? && !ExternalHttpdAuthentication.ipa_client_configured? raise ArgumentError, "ipa client not configured" end raise ArgumentError, "hostname needs to be defined" unless hostname end |