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_aem_health_check(opts = {}) ⇒ Object
Retrieve AEM Health Check.
-
#get_aem_health_check_wait_until_ok(opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Retrieve AEM health check with retries until its status is OK.
-
#get_agents(run_mode) ⇒ Object
List the name of all agents under /etc/replication.
-
#get_install_status ⇒ Object
Retrieve AEM install status.
-
#get_install_status_wait_until_finished(opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Retrieve AEM install status with retries until its status is finished.
-
#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.
26 27 28 29 30 |
# File 'lib/ruby_aem/resources/aem.rb', line 26 def initialize(client) @client = client @call_params = { } end |
Instance Method Details
#get_aem_health_check(opts = {}) ⇒ Object
Retrieve AEM Health Check. This is a custom API and requires github.com/shinesolutions/aem-healthcheck to be installed.
47 48 49 50 |
# File 'lib/ruby_aem/resources/aem.rb', line 47 def get_aem_health_check(opts = {}) @call_params = @call_params.merge(opts) @client.call(self.class, __callee__.to_s, @call_params) end |
#get_aem_health_check_wait_until_ok(opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Retrieve AEM health check with retries until its status is OK.
-
_retries: retries library's options (www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_trie, base_sleep_seconds, max_sleep_seconds
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/ruby_aem/resources/aem.rb', line 99 def get_aem_health_check_wait_until_ok( 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_aem_health_check(tags: opts[:tags], combine_tags_or: opts[:combine_tags_or]) is_ok = true result.data.each { |check| if check['status'] != 'OK' is_ok = false break end } if is_ok == false puts format('Retrieve AEM Health Check attempt #%d: %s but not ok yet', retries_count, result.) raise StandardError.new(result.) else puts format('Retrieve AEM Health Check attempt #%d: %s and ok', retries_count, result.) end rescue RubyAem::Error => err puts format('Retrieve AEM Health Check attempt #%d: %s', retries_count, err.) raise StandardError.new(err.) end } result end |
#get_agents(run_mode) ⇒ Object
List the name of all agents under /etc/replication.
147 148 149 150 |
# File 'lib/ruby_aem/resources/aem.rb', line 147 def get_agents(run_mode) @call_params[:run_mode] = run_mode @client.call(self.class, __callee__.to_s, @call_params) end |
#get_install_status ⇒ Object
Retrieve AEM install status.
155 156 157 |
# File 'lib/ruby_aem/resources/aem.rb', line 155 def get_install_status @client.call(self.class, __callee__.to_s, @call_params) end |
#get_install_status_wait_until_finished(opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Retrieve AEM install status with retries until its status is finished
-
_retries: retries library's options (www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_trie, base_sleep_seconds, max_sleep_seconds
164 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 |
# File 'lib/ruby_aem/resources/aem.rb', line 164 def get_install_status_wait_until_finished( 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_install_status item_count = result.response.body.status.item_count if result.response.body.status.finished == true && item_count.zero? puts format('Retrieve AEM install status attempt #%d: %s and finished', retries_count, result.) else puts format('Retrieve AEM install status attempt #%d: %s but not finished yet, still installing %d package(s)', retries_count, result., item_count) raise StandardError.new(result.) end rescue RubyAem::Error => err puts format('Retrieve AEM install status attempt #%d: %s', retries_count, err.) raise StandardError.new(err.) end } result end |
#get_login_page ⇒ Object
Retrieve AEM login page.
35 36 37 |
# File 'lib/ruby_aem/resources/aem.rb', line 35 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.
-
_retries: retries library's options (www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_trie, base_sleep_seconds, max_sleep_seconds
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 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ruby_aem/resources/aem.rb', line 57 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 format('Retrieve login page attempt #%d: %s but not ready yet', retries_count, result.) raise StandardError.new(result.) else puts format('Retrieve login page attempt #%d: %s and ready', retries_count, result.) end rescue RubyAem::Error => err puts format('Retrieve login page attempt #%d: %s', retries_count, err.) raise StandardError.new(err.) end } result end |