Class: RubyAem::Resources::Aem
- Inherits:
-
Object
- Object
- RubyAem::Resources::Aem
- Defined in:
- lib/ruby_aem/resources/aem.rb
Overview
AEM class contains API calls related to managing the AEM instance itself.
Instance Method Summary collapse
-
#get_login_page ⇒ Object
Retrieve AEM login page.
-
#get_login_page_wait_until_ready(opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Retrieve AEM login page with retries until it is successful.
-
#initialize(client) ⇒ Object
constructor
Initialise an AEM instance.
Constructor Details
#initialize(client) ⇒ Object
Initialise an AEM instance.
29 30 31 32 33 |
# File 'lib/ruby_aem/resources/aem.rb', line 29 def initialize(client) @client = client @call_params = { } end |
Instance Method Details
#get_login_page ⇒ Object
Retrieve AEM login page.
38 39 40 |
# File 'lib/ruby_aem/resources/aem.rb', line 38 def get_login_page() @client.call(self.class, __callee__.to_s, @call_params) end |
#get_login_page_wait_until_ready(opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Retrieve AEM login page with retries until it is successful. This is handy for waiting for AEM to start or restart Jetty.
-
_retries: retries library's options (www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_trie, base_sleep_seconds, max_sleep_seconds
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/ruby_aem/resources/aem.rb', line 48 def get_login_page_wait_until_ready( opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) opts[:_retries] ||= {} opts[:_retries][:max_tries] ||= 30 opts[:_retries][:base_sleep_seconds] ||= 2 opts[:_retries][:max_sleep_seconds] ||= 2 # ensure integer retries setting (Puppet 3 passes numeric string) opts[:_retries][:max_tries] = opts[:_retries][:max_tries].to_i opts[:_retries][:base_sleep_seconds] = opts[:_retries][:base_sleep_seconds].to_i opts[:_retries][:max_sleep_seconds] = opts[:_retries][:max_sleep_seconds].to_i result = nil with_retries(:max_tries => opts[:_retries][:max_tries], :base_sleep_seconds => opts[:_retries][:base_sleep_seconds], :max_sleep_seconds => opts[:_retries][:max_sleep_seconds]) { |retries_count| begin result = get_login_page() if result.response.body !~ /QUICKSTART_HOMEPAGE/ puts 'Retrieve login page attempt #%d: %s but not ready yet' % [retries_count, result.] raise StandardError.new(result.) else puts 'Retrieve login page attempt #%d: %s and ready' % [retries_count, result.] end rescue RubyAem::Error => err puts 'Retrieve login page attempt #%d: %s' % [retries_count, err.] raise StandardError.new(err.) end } result end |