foreman_rh_cloud 7.0.45 → 8.0.46
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/db/migrate/20221102110254_fix_rh_cloud_settings_category_to_dsl.rb +1 -1
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +12 -0
- data/lib/foreman_inventory_upload/generators/metadata.rb +4 -0
- data/lib/foreman_inventory_upload/generators/tags.rb +3 -5
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/tasks/hybrid_cloud.rake +63 -0
- data/locale/foreman_rh_cloud.pot +1091 -8
- data/locale/gemspec.rb +1 -1
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +11 -3
- data/test/factories/inventory_upload_factories.rb +15 -2
- data/test/test_plugin_helper.rb +17 -0
- data/test/unit/archived_report_generator_test.rb +2 -0
- data/test/unit/metadata_generator_test.rb +25 -0
- data/test/unit/slice_generator_test.rb +14 -9
- data/test/unit/tags_generator_test.rb +21 -7
- metadata +3 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8db662f6cd6809ba5dd5b183ec76330b4a1d4eb6db931136c8e34dcdf53c796c
|
4
|
+
data.tar.gz: e410219ca7fcbd0555d157f05123cc7c7618b29531157de42a3e3413d9d96eb4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 601501b2ec41be00150bbc9797ad9fe7c93a92aea619ca1781ef3df88224e3f6fb04b2c16e2c2e974832ef67926794108d3c8f2c7654d52056e25a218887cd55
|
7
|
+
data.tar.gz: 6a7ca4b57eb655c5d4c3a880f0deac4af3f86c6a4b71ddd4ff02b7adc4aa9bf5c0cb2a70731f5472ce763b841a75f755835e0674d489c6b5d51759ee9d1c85f3
|
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
class FixRhCloudSettingsCategoryToDsl < ActiveRecord::Migration[6.0]
|
4
4
|
def up
|
5
|
-
Setting.where(category: 'Setting::RhCloud').update_all(category: 'Setting')
|
5
|
+
Setting.where(category: 'Setting::RhCloud').update_all(category: 'Setting') if column_exists?(:settings, :category)
|
6
6
|
end
|
7
7
|
end
|
@@ -109,6 +109,18 @@ module ForemanInventoryUpload
|
|
109
109
|
IPAddr.new(max_obfuscated + 1, Socket::AF_INET).to_s
|
110
110
|
end
|
111
111
|
|
112
|
+
def hostname_match
|
113
|
+
bash_hostname = `uname -n`.chomp
|
114
|
+
foreman_hostname = ForemanRhCloud.foreman_host&.name
|
115
|
+
if bash_hostname == foreman_hostname
|
116
|
+
fqdn(foreman_hostname)
|
117
|
+
elsif Setting[:obfuscate_inventory_hostnames]
|
118
|
+
obfuscate_fqdn(bash_hostname)
|
119
|
+
else
|
120
|
+
bash_hostname
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
112
124
|
def bios_uuid(host)
|
113
125
|
value = fact_value(host, 'dmi::system::uuid') || ''
|
114
126
|
uuid_value(value)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module ForemanInventoryUpload
|
2
2
|
module Generators
|
3
3
|
class Metadata
|
4
|
+
include FactHelpers
|
4
5
|
def initialize(output = [])
|
5
6
|
@stream = JsonStream.new(output)
|
6
7
|
end
|
@@ -28,6 +29,9 @@ module ForemanInventoryUpload
|
|
28
29
|
@stream.simple_field('report_id', Foreman.uuid)
|
29
30
|
@stream.simple_field('host_inventory_api_version', '1.0')
|
30
31
|
@stream.simple_field('source', 'Satellite')
|
32
|
+
@stream.simple_field('reporting_host_name', hostname_match)
|
33
|
+
@stream.simple_field('reporting_host_ips', host_ips(ForemanRhCloud.foreman_host))
|
34
|
+
@stream.simple_field('reporting_host_bios_uuid', bios_uuid(ForemanRhCloud.foreman_host))
|
31
35
|
@stream.simple_field('source_metadata', metadata)
|
32
36
|
@stream.object_field('report_slices', :last) do
|
33
37
|
yield(self)
|
@@ -45,11 +45,9 @@ module ForemanInventoryUpload
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def content_data
|
48
|
-
[
|
49
|
-
|
50
|
-
|
51
|
-
] +
|
52
|
-
(@host.activation_keys || []).map { |item| ['activation_key', item.name] }
|
48
|
+
(@host.lifecycle_environments.uniq || []).map { |item| ['lifecycle_environment', item.name] } +
|
49
|
+
(@host.activation_keys || []).map { |item| ['activation_key', item.name] } +
|
50
|
+
(@host.content_views || []).map { |item| ['content_view', item.name] }
|
53
51
|
end
|
54
52
|
|
55
53
|
def satellite_server_data
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'io/console'
|
2
|
+
|
3
|
+
namespace :rh_cloud do |args|
|
4
|
+
desc 'Register Satellite Organization with Hybrid Cloud API. \
|
5
|
+
Specify org_id=x replace your organization ID with x. \
|
6
|
+
Specify SATELLITE_RH_CLOUD_URL=https://x with the Hybrid Cloud endpoint you are connecting to.'
|
7
|
+
task hybridcloud_register: [:environment] do
|
8
|
+
include ::ForemanRhCloud::CertAuth
|
9
|
+
include ::InsightsCloud::CandlepinCache
|
10
|
+
|
11
|
+
def logger
|
12
|
+
@logger ||= Logger.new(STDOUT)
|
13
|
+
end
|
14
|
+
|
15
|
+
def registrations_url
|
16
|
+
logger.warn("Custom url is not set, using the default one: #{ForemanRhCloud.base_url}") if ENV['SATELLITE_RH_CLOUD_URL'].empty?
|
17
|
+
ForemanRhCloud.base_url + '/api/identity/certificate/registrations'
|
18
|
+
end
|
19
|
+
|
20
|
+
if ENV['org_id'].nil?
|
21
|
+
logger.error('ERROR: org_id needs to be specified.')
|
22
|
+
exit(1)
|
23
|
+
end
|
24
|
+
|
25
|
+
organization = Organization.find_by(id: ENV['org_id'].to_i) # saw this coming in as a string, so making sure it gets passed as an integer.
|
26
|
+
|
27
|
+
@uid = cp_owner_id(organization)
|
28
|
+
logger.error('Organization provided does not have a manifest imported.') + exit(1) if @uid.nil?
|
29
|
+
|
30
|
+
puts 'Paste your token, output will be hidden.'
|
31
|
+
@token = STDIN.noecho(&:gets).chomp
|
32
|
+
logger.error('Token was not entered.') + exit(1) if @token.empty?
|
33
|
+
|
34
|
+
def headers
|
35
|
+
{
|
36
|
+
Authorization: "Bearer #{@token}"
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def payload
|
41
|
+
{
|
42
|
+
"uid": @uid
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
def method
|
47
|
+
:post
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
response = execute_cloud_request(
|
52
|
+
organization: organization,
|
53
|
+
method: method,
|
54
|
+
url: registrations_url,
|
55
|
+
headers: headers,
|
56
|
+
payload: payload.to_json
|
57
|
+
)
|
58
|
+
logger.debug(response)
|
59
|
+
rescue Exception => ex
|
60
|
+
logger.error(ex)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|