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_crxde_status ⇒ Object
Retrieve AEM CRXDE Status.
-
#get_development_bundles_status ⇒ Object
Check whether development bundles are active as per AEM Security Checklist experienceleague.adobe.com/docs/experience-manager-65/administering/security/security-checklist.html The checklist documentation also includes ‘com.adobe.granite.crxde-support’, however this bundle does not exist on AEM 6.5 so it has been excluded from this implementation.
-
#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.
-
#get_package_manager_servlet_status ⇒ Object
Retrieve AEM CRX Package Manager Servlet status state.
-
#get_package_manager_servlet_status_wait_until_ready(opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Retrieve AEM CRX Package Manager Servlet status state.
-
#get_packages ⇒ Object
Get a list of all packages available on AEM instance.
-
#get_product_info ⇒ Object
Retrieve AEM Product informations.
-
#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_aem_health_check(opts = {}) ⇒ Object
Retrieve AEM Health Check. This is a custom API and requires github.com/shinesolutions/aem-healthcheck to be installed.
-
tags: comma separated tags of AEM Health Check tags
-
combine_tags_or: if true, the check needs to only pass one of the check tags in order to get the health check pass, if false, all check tags need to pass in order to get the health check pass.
59 60 61 62 |
# File 'lib/ruby_aem/resources/aem.rb', line 59 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
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/ruby_aem/resources/aem.rb', line 118 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 #%<retries_count>d: %<message>s but not ok yet', retries_count: retries_count, message: result.) raise StandardError.new(result.) else puts format('Retrieve AEM Health Check attempt #%<retries_count>d: %<message>s and ok', retries_count: retries_count, message: result.) end rescue RubyAem::Error => e puts format('Retrieve AEM Health Check attempt #%<retries_count>d: %<message>s', retries_count: retries_count, message: e.) raise StandardError.new(e.) end } result end |
#get_agents(run_mode) ⇒ Object
List the name of all agents under /etc/replication.
199 200 201 202 |
# File 'lib/ruby_aem/resources/aem.rb', line 199 def get_agents(run_mode) @call_params[:run_mode] = run_mode @client.call(self.class, __callee__.to_s, @call_params) end |
#get_crxde_status ⇒ Object
Retrieve AEM CRXDE Status
45 46 47 |
# File 'lib/ruby_aem/resources/aem.rb', line 45 def get_crxde_status @client.call(self.class, __callee__.to_s, @call_params) end |
#get_development_bundles_status ⇒ Object
Check whether development bundles are active as per AEM Security Checklist experienceleague.adobe.com/docs/experience-manager-65/administering/security/security-checklist.html The checklist documentation also includes ‘com.adobe.granite.crxde-support’, however this bundle does not exist on AEM 6.5 so it has been excluded from this implementation. True result data indicates that the development bundles are active, false otherwise.
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/ruby_aem/resources/aem.rb', line 294 def get_development_bundles_status crx_explorer_bundle = RubyAem::Resources::Bundle.new(@client, 'com.adobe.granite.crx-explorer') crxde_lite_bundle = RubyAem::Resources::Bundle.new(@client, 'com.adobe.granite.crxde-lite') result = RubyAem::Result.new(nil, nil) crx_explorer_bundle_is_active = crx_explorer_bundle.is_active.data crxde_lite_bundle_is_active = crxde_lite_bundle.is_active.data if crx_explorer_bundle_is_active && crxde_lite_bundle_is_active result. = 'Development bundles are all active' result.data = true elsif !crx_explorer_bundle_is_active && !crxde_lite_bundle_is_active result. = 'Development bundles are all inactive' result.data = false else result. = "Development bundles are partially active. crx_explorer_bundle is active: #{crx_explorer_bundle_is_active}, crxde_lite_bundle is active: #{crxde_lite_bundle_is_active}" result.data = false end result end |
#get_install_status ⇒ Object
Retrieve AEM install status.
207 208 209 |
# File 'lib/ruby_aem/resources/aem.rb', line 207 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
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 249 250 251 252 |
# File 'lib/ruby_aem/resources/aem.rb', line 216 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 #%<retries_count>d: %<message>s and finished', retries_count: retries_count, message: result.) else puts format('Retrieve AEM install status attempt #%<retries_count>d: %<message>s but not finished yet, still installing %<item_count>d package(s)', retries_count: retries_count, message: result., item_count: item_count) raise StandardError.new(result.) end rescue RubyAem::Error => e puts format('Retrieve AEM install status attempt #%<retries_count>d: %<message>s', retries_count: retries_count, message: e.) raise StandardError.new(e.) end } result end |
#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.
-
_retries: retries library’s options (www.rubydoc.info/gems/retries/0.0.5#Usage), restricted to max_trie, base_sleep_seconds, max_sleep_seconds
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/ruby_aem/resources/aem.rb', line 76 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 #%<retries_count>d: %<message>s but not ready yet', retries_count: retries_count, message: result.) raise StandardError.new(result.) else puts format('Retrieve login page attempt #%<retries_count>d: %<message>s and ready', retries_count: retries_count, message: result.) end rescue RubyAem::Error => e puts format('Retrieve login page attempt #%<retries_count>d: %<message>s', retries_count: retries_count, message: e.) raise StandardError.new(e.) end } result end |
#get_package_manager_servlet_status ⇒ Object
Retrieve AEM CRX Package Manager Servlet status state.
67 68 69 |
# File 'lib/ruby_aem/resources/aem.rb', line 67 def get_package_manager_servlet_status @client.call(self.class, __callee__.to_s, @call_params) end |
#get_package_manager_servlet_status_wait_until_ready(opts = { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } }) ⇒ Object
Retrieve AEM CRX Package Manager Servlet status state. 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
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 |
# File 'lib/ruby_aem/resources/aem.rb', line 167 def get_package_manager_servlet_status_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| result = get_package_manager_servlet_status puts format('Check CRX Package Manager service attempt #%<retries_count>d: %<result_message>s', retries_count: retries_count, result_message: result.) raise StandardError.new(result.) if result.data == false } result end |
#get_packages ⇒ Object
Get a list of all packages available on AEM instance. The list of packages are returned as result data. Example:
"group" => "shinesolutions",
"name" => "aem-password-reset-content",
"version" => "1.0.1",
"downloadName" => "aem-password-reset-content-1.0.1.zip",
"size" => "23579",
"created" => "Tue, 4 Apr 2017 13:38:35 +1000",
"createdBy" => "root",
"lastModified" => nil,
"lastModifiedBy" => "null",
"lastUnpacked" => "Wed, 18 Apr 2018 22:57:01 +1000",
"lastUnpackedBy" => "admin"
272 273 274 275 276 277 278 |
# File 'lib/ruby_aem/resources/aem.rb', line 272 def get_packages result = @client.call(self.class, __callee__.to_s, @call_params) packages = REXML::XPath.match(REXML::Document.new(result.data.to_s), '//packages/package') result_copy = RubyAem::Result.new(result., result.response) result_copy.data = packages result_copy end |
#get_product_info ⇒ Object
Retrieve AEM Product informations
283 284 285 |
# File 'lib/ruby_aem/resources/aem.rb', line 283 def get_product_info @client.call(self.class, __callee__.to_s, @call_params) end |