Module: ForemanMaintain::Concerns::Downstream

Defined in:
lib/foreman_maintain/concerns/downstream.rb

Instance Method Summary collapse

Instance Method Details

#absent_repos(version) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/foreman_maintain/concerns/downstream.rb', line 35

def absent_repos(version)
  all_repo_lines = execute(%(LANG=en_US.utf-8 subscription-manager repos --list 2>&1 | ) +
                            %(grep '^Repo ID:')).split("\n")
  all_repos = all_repo_lines.map { |line| line.split(/\s+/).last }
  repos_required = rh_repos(version)
  repos_found = repos_required & all_repos
  repos_required - repos_found
end

#at_least_version?(version) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/foreman_maintain/concerns/downstream.rb', line 12

def at_least_version?(version)
  Gem::Version.new(current_version) >= Gem::Version.new(version)
end

#current_minor_versionObject



16
17
18
# File 'lib/foreman_maintain/concerns/downstream.rb', line 16

def current_minor_version
  current_version.to_s[/^\d+\.\d+/]
end

#current_versionObject

Raises:

  • (NotImplementedError)


4
5
6
# File 'lib/foreman_maintain/concerns/downstream.rb', line 4

def current_version
  raise NotImplementedError
end

#fm_pkg_and_cmd_nameObject



57
58
59
# File 'lib/foreman_maintain/concerns/downstream.rb', line 57

def fm_pkg_and_cmd_name
  %w[satellite-maintain satellite-maintain]
end

#less_than_version?(version) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/foreman_maintain/concerns/downstream.rb', line 8

def less_than_version?(version)
  Gem::Version.new(current_version) < Gem::Version.new(version)
end

#package_nameObject

Raises:

  • (NotImplementedError)


53
54
55
# File 'lib/foreman_maintain/concerns/downstream.rb', line 53

def package_name
  raise NotImplementedError
end

#rhsm_refreshObject



44
45
46
# File 'lib/foreman_maintain/concerns/downstream.rb', line 44

def rhsm_refresh
  execute!(%(subscription-manager refresh))
end

#setup_repositories(version) ⇒ Object

TODO: Modify activation_key changes as per server



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/foreman_maintain/concerns/downstream.rb', line 21

def setup_repositories(version)
  activation_key = ENV['EXTERNAL_SAT_ACTIVATION_KEY']
  org = ENV['EXTERNAL_SAT_ORG']
  if activation_key
    org_options = org ? %(--org #{shellescape(org)}) : ''
    execute!(%(subscription-manager register #{org_options}\
                --activationkey #{shellescape(activation_key)} --force))
  else
    execute!(%(subscription-manager repos --disable '*'))
    enable_options = rh_repos(version).map { |r| "--enable=#{r}" }.join(' ')
    execute!(%(subscription-manager repos #{enable_options}))
  end
end

#subscribed_using_activation_key?Boolean

TODO: Verify this is valid for capsule?

Returns:

  • (Boolean)


49
50
51
# File 'lib/foreman_maintain/concerns/downstream.rb', line 49

def subscribed_using_activation_key?
  ENV['EXTERNAL_SAT_ACTIVATION_KEY'] && ENV['EXTERNAL_SAT_ORG']
end