foreman_rh_cloud 12.2.17 → 12.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/foreman_inventory_upload/async/upload_report_direct_job.rb +3 -2
- data/lib/foreman_inventory_upload.rb +16 -1
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/tasks/rh_cloud_inventory.rake +4 -0
- data/package.json +1 -1
- data/test/controllers/accounts_controller_test.rb +43 -0
- data/test/test_plugin_helper.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 79c93d459f33a153d6d5ef0477cddc3b0f4b992716bb1a9b9352d0d8274b9185
|
|
4
|
+
data.tar.gz: 0f7d20917c23789936882787bcb492353a56ac4061b27fcabb138a93dc9c9909
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61917464374fddd39409ba0e4dd5c8f2b40a8eb18091a0e4af381b78930a460186c334f5e7b93a5b052b6dff98101551da59390f82ee94880601abe08bf645dc
|
|
7
|
+
data.tar.gz: 49af34b52d989a0558c538f5da8e027d26953261d69cbea8ed5535c11ae407ab50b0b7c2dcf78302b7281cfff2a6f1c74dc93cf0f8cb942a15d141263000a93d
|
|
@@ -95,8 +95,8 @@ module ForemanInventoryUpload
|
|
|
95
95
|
begin
|
|
96
96
|
upload_file(cer_path)
|
|
97
97
|
progress_output.write_line("Upload completed successfully")
|
|
98
|
-
move_to_done_folder
|
|
99
|
-
progress_output.write_line("Uploaded
|
|
98
|
+
done_path = move_to_done_folder
|
|
99
|
+
progress_output.write_line("Uploaded report moved to #{done_path}")
|
|
100
100
|
progress_output.status = "pid #{Process.pid} exit 0"
|
|
101
101
|
rescue StandardError => e
|
|
102
102
|
progress_output.write_line("Upload failed: #{e.message}")
|
|
@@ -139,6 +139,7 @@ module ForemanInventoryUpload
|
|
|
139
139
|
done_file = ForemanInventoryUpload.done_file_path(File.basename(filename))
|
|
140
140
|
FileUtils.mv(filename, done_file)
|
|
141
141
|
logger.debug("Moved #{filename} to #{done_file}")
|
|
142
|
+
done_file
|
|
142
143
|
end
|
|
143
144
|
|
|
144
145
|
def certificate
|
|
@@ -32,7 +32,18 @@ module ForemanInventoryUpload
|
|
|
32
32
|
|
|
33
33
|
def self.report_file_paths(organization_id)
|
|
34
34
|
filename = facts_archive_name(organization_id)
|
|
35
|
-
|
|
35
|
+
# Report files start in generated
|
|
36
|
+
# They are then MOVED (not copied) to uploads, then done.
|
|
37
|
+
# When they are moved to the new folder, they overwrite any file with the same name.
|
|
38
|
+
# If it's a generate-only, it will be in generated
|
|
39
|
+
# Failed or incomplete uploads will be in uploads
|
|
40
|
+
# Completed uploads will be in done
|
|
41
|
+
# The ordering here ensures we get the correct file path every time.
|
|
42
|
+
Dir[
|
|
43
|
+
ForemanInventoryUpload.generated_reports_file_path(filename),
|
|
44
|
+
ForemanInventoryUpload.uploads_file_path(filename),
|
|
45
|
+
ForemanInventoryUpload.done_file_path(filename)
|
|
46
|
+
]
|
|
36
47
|
end
|
|
37
48
|
|
|
38
49
|
def self.generated_reports_folder
|
|
@@ -44,6 +55,10 @@ module ForemanInventoryUpload
|
|
|
44
55
|
)
|
|
45
56
|
end
|
|
46
57
|
|
|
58
|
+
def self.generated_reports_file_path(filename)
|
|
59
|
+
File.join(ForemanInventoryUpload.generated_reports_folder, filename)
|
|
60
|
+
end
|
|
61
|
+
|
|
47
62
|
def self.outputs_folder
|
|
48
63
|
@outputs_folder ||= ensure_folder(File.join(ForemanInventoryUpload.base_folder, 'outputs/'))
|
|
49
64
|
end
|
|
@@ -46,6 +46,10 @@ namespace :rh_cloud_inventory do
|
|
|
46
46
|
filter,
|
|
47
47
|
false # don't upload; the user ran report:generate and not report:generate_upload
|
|
48
48
|
)
|
|
49
|
+
unless Setting[:subscription_connection_enabled]
|
|
50
|
+
report_paths = ForemanInventoryUpload.report_file_paths(organization_id)
|
|
51
|
+
puts "Report saved to #{report_paths.first}" if report_paths.any?
|
|
52
|
+
end
|
|
49
53
|
end
|
|
50
54
|
puts "Check the Uploading tab for report uploading status." if Setting[:subscription_connection_enabled]
|
|
51
55
|
end
|
data/package.json
CHANGED
|
@@ -5,6 +5,49 @@ class AccountsControllerTest < ActionController::TestCase
|
|
|
5
5
|
|
|
6
6
|
include FolderIsolation
|
|
7
7
|
|
|
8
|
+
test 'report_file_paths finds report in generated_reports folder' do
|
|
9
|
+
test_org = FactoryBot.create(:organization)
|
|
10
|
+
filename = ForemanInventoryUpload.facts_archive_name(test_org.id)
|
|
11
|
+
|
|
12
|
+
generated_path = ForemanInventoryUpload.generated_reports_file_path(filename)
|
|
13
|
+
FileUtils.mkdir_p(File.dirname(generated_path))
|
|
14
|
+
FileUtils.touch(generated_path)
|
|
15
|
+
|
|
16
|
+
paths = ForemanInventoryUpload.report_file_paths(test_org.id)
|
|
17
|
+
assert_includes paths, generated_path
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test 'report_file_paths finds report in uploads folder' do
|
|
21
|
+
test_org = FactoryBot.create(:organization)
|
|
22
|
+
filename = ForemanInventoryUpload.facts_archive_name(test_org.id)
|
|
23
|
+
|
|
24
|
+
uploads_path = ForemanInventoryUpload.uploads_file_path(filename)
|
|
25
|
+
FileUtils.mkdir_p(File.dirname(uploads_path))
|
|
26
|
+
FileUtils.touch(uploads_path)
|
|
27
|
+
|
|
28
|
+
paths = ForemanInventoryUpload.report_file_paths(test_org.id)
|
|
29
|
+
assert_includes paths, uploads_path
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test 'report_file_paths finds report in done folder' do
|
|
33
|
+
test_org = FactoryBot.create(:organization)
|
|
34
|
+
filename = ForemanInventoryUpload.facts_archive_name(test_org.id)
|
|
35
|
+
|
|
36
|
+
done_path = ForemanInventoryUpload.done_file_path(filename)
|
|
37
|
+
FileUtils.mkdir_p(File.dirname(done_path))
|
|
38
|
+
FileUtils.touch(done_path)
|
|
39
|
+
|
|
40
|
+
paths = ForemanInventoryUpload.report_file_paths(test_org.id)
|
|
41
|
+
assert_includes paths, done_path
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
test 'report_file_paths returns empty when no report exists' do
|
|
45
|
+
test_org = FactoryBot.create(:organization)
|
|
46
|
+
|
|
47
|
+
paths = ForemanInventoryUpload.report_file_paths(test_org.id)
|
|
48
|
+
assert_empty paths
|
|
49
|
+
end
|
|
50
|
+
|
|
8
51
|
test 'Returns statuses for each process type' do
|
|
9
52
|
test_org = FactoryBot.create(:organization)
|
|
10
53
|
|
data/test/test_plugin_helper.rb
CHANGED
|
@@ -31,6 +31,7 @@ module FolderIsolation
|
|
|
31
31
|
ForemanInventoryUpload.stubs(:base_folder).returns(@tmpdir)
|
|
32
32
|
ForemanInventoryUpload.instance_variable_set(:@outputs_folder, nil)
|
|
33
33
|
ForemanInventoryUpload.instance_variable_set(:@uploads_folders, nil)
|
|
34
|
+
ForemanInventoryUpload.instance_variable_set(:@generated_reports_folder, nil)
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
teardown do
|