Module: PuppetX::EnterpriseModules::Oracle::Utilities

Defined in:
lib/puppet_x/enterprisemodules/oracle/utilities.rb

Overview

Docs

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(parent) ⇒ Object



11
12
13
# File 'lib/puppet_x/enterprisemodules/oracle/utilities.rb', line 11

def self.included(parent)
  parent.extend(Utilities)
end

Instance Method Details

#generated_password(length = 12) ⇒ Object

Generate a valid Oracle password



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/puppet_x/enterprisemodules/oracle/utilities.rb', line 18

def generated_password(length = 12)
  fail "Request password length is #{length}, but needs to be at least 9" if length < 9

  resulting_length = length - 9
  random_letter +
    (random_character(resulting_length) +
     random_special_character(2) +
     random_uppercase(2) +
     random_lowercase(2) +
     random_digit(2)).chars.sort_by { rand }.join
end

#random_character(length = 1) ⇒ Object



56
57
58
# File 'lib/puppet_x/enterprisemodules/oracle/utilities.rb', line 56

def random_character(length = 1)
  (('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a).sort_by { rand }.join[0...length]
end

#random_digit(length = 1) ⇒ Object



51
52
53
# File 'lib/puppet_x/enterprisemodules/oracle/utilities.rb', line 51

def random_digit(length = 1)
  ('0'..'9').to_a.sort_by { rand }.join[0...length]
end

#random_letter(length = 1) ⇒ Object



31
32
33
# File 'lib/puppet_x/enterprisemodules/oracle/utilities.rb', line 31

def random_letter(length = 1)
  (('A'..'Z').to_a + ('a'..'z').to_a).sort_by { rand }.join[0...length]
end

#random_lowercase(length = 1) ⇒ Object



46
47
48
# File 'lib/puppet_x/enterprisemodules/oracle/utilities.rb', line 46

def random_lowercase(length = 1)
  ('a'..'z').to_a.sort_by { rand }.join[0...length]
end

#random_special_character(length = 1) ⇒ Object



36
37
38
# File 'lib/puppet_x/enterprisemodules/oracle/utilities.rb', line 36

def random_special_character(length = 1)
  '!@#$%^*()_+{}|:>?<[]\\;,.~'.chars.sort_by { rand }.join[0...length]
end

#random_uppercase(length = 1) ⇒ Object



41
42
43
# File 'lib/puppet_x/enterprisemodules/oracle/utilities.rb', line 41

def random_uppercase(length = 1)
  ('A'..'Z').to_a.sort_by { rand }.join[0...length]
end