Class: RubyAem::Resources::Aem

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(client) ⇒ Object

Initialise an AEM instance.

Parameters:

  • client

    RubyAem::Client



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.

Parameters:

  • tags

    comma separated tags

  • combine_tags_or

Returns:

  • RubyAem::Result



50
51
52
53
54
# File 'lib/ruby_aem/resources/aem.rb', line 50

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.

Parameters:

  • opts (defaults to: { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } })

    optional parameters:

Returns:

  • RubyAem::Result



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
142
143
# File 'lib/ruby_aem/resources/aem.rb', line 102

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 'Retrieve AEM Health Check attempt #%d: %s but not ok yet' % [retries_count, result.message]
        raise StandardError.new(result.message)
      else
        puts 'Retrieve AEM Health Check attempt #%d: %s and ok' % [retries_count, result.message]
      end
    rescue RubyAem::Error => err
      puts 'Retrieve AEM Health Check attempt #%d: %s' % [retries_count, err.message]
      raise StandardError.new(err.message)
    end
  }
  result
end

#get_login_pageObject

Retrieve AEM login page.

Returns:

  • RubyAem::Result



38
39
40
# File 'lib/ruby_aem/resources/aem.rb', line 38

def ()
  @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.

Parameters:

  • opts (defaults to: { _retries: { max_tries: 30, base_sleep_seconds: 2, max_sleep_seconds: 2 } })

    optional parameters:

Returns:

  • RubyAem::Result



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
93
94
95
# File 'lib/ruby_aem/resources/aem.rb', line 61

def (
  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 = ()
      if result.response.body !~ /QUICKSTART_HOMEPAGE/
        puts 'Retrieve login page attempt #%d: %s but not ready yet' % [retries_count, result.message]
        raise StandardError.new(result.message)
      else
        puts 'Retrieve login page attempt #%d: %s and ready' % [retries_count, result.message]
      end
    rescue RubyAem::Error => err
      puts 'Retrieve login page attempt #%d: %s' % [retries_count, err.message]
      raise StandardError.new(err.message)
    end
  }
  result
end