Class: LinuxAdmin::SubscriptionManager
Constant Summary
collapse
- SATELLITE6_SERVER_CERT_PATH =
"pub/candlepin-cert-consumer-latest.noarch.rpm"
Constants inherited
from LinuxAdmin
VERSION
Instance Method Summary
collapse
method_missing, registration_type
Methods included from Common
#cmd, #run
Instance Method Details
#available_subscriptions ⇒ Object
77
78
79
80
81
|
# File 'lib/linux_admin/registration_system/subscription_manager.rb', line 77
def available_subscriptions
cmd = "subscription-manager list --all --available"
output = run!(cmd).output
parse_output(output).index_by {|i| i[:pool_id]}
end
|
#organizations(options) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/linux_admin/registration_system/subscription_manager.rb', line 26
def organizations(options)
raise ArgumentError, "username and password are required" unless options[:username] && options[:password]
install_server_certificate(options[:server_url], SATELLITE6_SERVER_CERT_PATH) if options[:server_url]
cmd = "subscription-manager orgs"
params = {"--username=" => options[:username], "--password=" => options[:password]}
params.merge!(proxy_params(options))
params["--serverurl="] = options[:server_url] if options[:server_url]
result = run!(cmd, :params => params)
parse_output(result.output).index_by {|i| i[:name]}
end
|
#refresh ⇒ Object
22
23
24
|
# File 'lib/linux_admin/registration_system/subscription_manager.rb', line 22
def refresh
run!("subscription-manager refresh")
end
|
#register(options) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/linux_admin/registration_system/subscription_manager.rb', line 41
def register(options)
raise ArgumentError, "username and password are required" unless options[:username] && options[:password]
install_server_certificate(options[:server_url], SATELLITE6_SERVER_CERT_PATH) if options[:server_url]
cmd = "subscription-manager register"
params = {"--username=" => options[:username], "--password=" => options[:password]}
params.merge!(proxy_params(options))
params["--org="] = options[:org] if options[:server_url] && options[:org]
params["--serverurl="] = options[:server_url] if options[:server_url]
run!(cmd, :params => params)
end
|
#registered? ⇒ Boolean
18
19
20
|
# File 'lib/linux_admin/registration_system/subscription_manager.rb', line 18
def registered?
run("subscription-manager identity").exit_status == 0
end
|
#run!(cmd, options = {}) ⇒ Object
5
6
7
8
9
10
|
# File 'lib/linux_admin/registration_system/subscription_manager.rb', line 5
def run!(cmd, options = {})
super(cmd, options)
rescue CommandResultError => err
raise CredentialError.new(err.result) if err.result.error.downcase.include?("invalid username or password")
raise
end
|
#subscribe(options) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/linux_admin/registration_system/subscription_manager.rb', line 56
def subscribe(options)
cmd = "subscription-manager attach"
params = proxy_params(options)
if options[:pools].blank?
params.merge!({"--auto" => nil})
else
pools = options[:pools].collect {|pool| ["--pool", pool]}
params = params.to_a + pools
end
run!(cmd, :params => params)
end
|
#subscribed_products ⇒ Object
70
71
72
73
74
75
|
# File 'lib/linux_admin/registration_system/subscription_manager.rb', line 70
def subscribed_products
cmd = "subscription-manager list --installed"
output = run!(cmd).output
parse_output(output).select {|p| p[:status].downcase == "subscribed"}.collect {|p| p[:product_id]}
end
|
#validate_credentials(options) ⇒ Object
14
15
16
|
# File 'lib/linux_admin/registration_system/subscription_manager.rb', line 14
def validate_credentials(options)
!!organizations(options)
end
|