Class: Katello::Resources::Candlepin::Owner
Constant Summary
Constants inherited
from HttpResource
HttpResource::REQUEST_MAP
Instance Attribute Summary
Attributes inherited from HttpResource
#json
Class Method Summary
collapse
-
.all ⇒ Object
-
.create(key, description, content_access_mode: 'org_environment') ⇒ Object
Set the contentPrefix at creation time so that the client will get content only for the org it has been subscribed to.
-
.create_user(_key, username, password) ⇒ Object
create the first user for owner.
-
.destroy(key) ⇒ Object
-
.destroy_imports(organization_name, wait_until_complete: false) ⇒ Object
-
.find(key) ⇒ Object
-
.generate_ueber_cert(key) ⇒ Object
-
.get_ueber_cert(key) ⇒ Object
-
.get_ueber_cert_pkcs12(key, name = nil, password = nil) ⇒ Object
-
.import(organization_name, path_to_file, options) ⇒ Object
-
.imports(organization_name) ⇒ Object
-
.pools(owner_label, filter = {}) ⇒ Object
-
.product_content(organization_name) ⇒ Object
-
.service_levels(uuid) ⇒ Object
-
.statistics(key) ⇒ Object
-
.system_purpose(key) ⇒ Object
-
.update(key, attrs) ⇒ Object
path
default_headers, fetch_paged, included_list, logger, name_to_key, process_response, raise_rest_client_exception
#[], #[]=, hash_to_query, #initialize, issue_request, join_path, logger, process_response, raise_rest_client_exception, rest_client
#filter_sensitive_data
Class Method Details
.all ⇒ Object
8
9
10
11
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 8
def all
response = self.get(path, )
JSON.parse(response.body)
end
|
.create(key, description, content_access_mode: 'org_environment') ⇒ Object
Set the contentPrefix at creation time so that the client will get content only for the org it has been subscribed to
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 15
def create(key, description, content_access_mode: 'org_environment')
attrs = {
:key => key,
:displayName => description,
:contentPrefix => "/#{key}/$env",
:contentAccessMode => content_access_mode,
:contentAccessModeList => ['entitlement', 'org_environment'].join(',')
}
owner_json = self.post(path, attrs.to_json, self.).body
JSON.parse(owner_json).with_indifferent_access
end
|
.create_user(_key, username, password) ⇒ Object
create the first user for owner
28
29
30
31
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 28
def create_user(_key, username, password)
CPUser.create(:username => name_to_key(username), :password => name_to_key(password), :superAdmin => true)
end
|
.destroy(key) ⇒ Object
33
34
35
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 33
def destroy(key)
self.delete(path(key), User.).code.to_i
end
|
.destroy_imports(organization_name, wait_until_complete: false) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 63
def destroy_imports(organization_name, wait_until_complete: false)
response_json = self.delete(join_path(path(organization_name), 'imports'), self.)
response = JSON.parse(response_json).with_indifferent_access
if wait_until_complete && response['state'] == 'CREATED'
while !response['state'].nil? && response['state'] != 'FINISHED' && response['state'] != 'ERROR'
path = join_path('candlepin', response['statusPath'][1..-1])
response_json = self.get(path, self.)
response = JSON.parse(response_json).with_indifferent_access
end
end
response
end
|
.find(key) ⇒ Object
37
38
39
40
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 37
def find(key)
owner_json = self.get(path(key), {'accept' => 'application/json'}.merge(User.)).body
JSON.parse(owner_json).with_indifferent_access
end
|
.generate_ueber_cert(key) ⇒ Object
100
101
102
103
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 100
def generate_ueber_cert(key)
ueber_cert_json = self.post(join_path(path(key), "uebercert"), {}.to_json, self.).body
JSON.parse(ueber_cert_json).with_indifferent_access
end
|
.get_ueber_cert(key) ⇒ Object
105
106
107
108
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 105
def get_ueber_cert(key)
ueber_cert_json = self.get(join_path(path(key), "uebercert"), {'accept' => 'application/json'}.merge(User.)).body
JSON.parse(ueber_cert_json).with_indifferent_access
end
|
.get_ueber_cert_pkcs12(key, name = nil, password = nil) ⇒ Object
110
111
112
113
114
115
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 110
def get_ueber_cert_pkcs12(key, name = nil, password = nil)
certs = get_ueber_cert(key)
c = OpenSSL::X509::Certificate.new certs["cert"]
p = OpenSSL::PKey::RSA.new certs["key"]
OpenSSL::PKCS12.create(password, name, p, c, nil, "PBE-SHA1-3DES", "PBE-SHA1-3DES")
end
|
.import(organization_name, path_to_file, options) ⇒ Object
49
50
51
52
53
54
55
56
57
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 49
def import(organization_name, path_to_file, options)
path = join_path(path(organization_name), 'imports/async')
if options[:force] || SETTINGS[:katello].key?(:force_manifest_import)
path += "?force=#{SETTINGS[:katello][:force_manifest_import]}"
end
response = self.post(path, {:import => File.new(path_to_file, 'rb')}, self..except('content-type'))
JSON.parse(response)
end
|
.imports(organization_name) ⇒ Object
77
78
79
80
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 77
def imports(organization_name)
imports_json = self.get(join_path(path(organization_name), 'imports'), self.)
::Katello::Util::Data.array_with_indifferent_access JSON.parse(imports_json)
end
|
.pools(owner_label, filter = {}) ⇒ Object
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 82
def pools(owner_label, filter = {})
filter[:add_future] ||= true
params = hash_to_query(filter)
if owner_label
params += '&attribute=unmapped_guests_only:!true'
json_str = self.get(join_path(path(owner_label), 'pools') + params, self.).body
else
json_str = self.get(join_path('candlepin', 'pools') + params, self.).body
end
::Katello::Util::Data.array_with_indifferent_access JSON.parse(json_str)
end
|
.product_content(organization_name) ⇒ Object
59
60
61
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 59
def product_content(organization_name)
Product.all(organization_name, [:id, :productContent])
end
|
.service_levels(uuid) ⇒ Object
117
118
119
120
121
122
123
124
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 117
def service_levels(uuid)
response = Candlepin::CandlepinResource.get(join_path(path(uuid), 'servicelevels'), self.).body
if response.empty?
return []
else
JSON.parse(response)
end
end
|
.statistics(key) ⇒ Object
95
96
97
98
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 95
def statistics(key)
json_str = self.get(join_path(path(key), 'statistics'), self.).body
::Katello::Util::Data.array_with_indifferent_access JSON.parse(json_str)
end
|
.system_purpose(key) ⇒ Object
126
127
128
129
130
131
132
133
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 126
def system_purpose(key)
response = Candlepin::CandlepinResource.get(join_path(path(key), 'system_purpose'), self.).body
if response.empty?
return []
else
JSON.parse(response)['systemPurposeAttributes']
end
end
|
.update(key, attrs) ⇒ Object
42
43
44
45
46
47
|
# File 'app/lib/katello/resources/candlepin/owner.rb', line 42
def update(key, attrs)
owner = find(key)
owner.merge!(attrs)
owner.merge!(:contentAccessModeList => ['entitlement', 'org_environment'].join(','))
self.put(path(key), JSON.generate(owner), self.).body
end
|