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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0df237afaaed946309bf58184191f10cc41adad7ad746077f7445a26d880e24f
4
- data.tar.gz: 302e496860920fc29db9807621fd8ceb442d08af831184ee8dd743963e153b50
3
+ metadata.gz: 79c93d459f33a153d6d5ef0477cddc3b0f4b992716bb1a9b9352d0d8274b9185
4
+ data.tar.gz: 0f7d20917c23789936882787bcb492353a56ac4061b27fcabb138a93dc9c9909
5
5
  SHA512:
6
- metadata.gz: 20278c38dcedc487a60321c837bbdb4bfe20f3db46873a7482ab43922c91b9d8c4b1529a2d4e024bf24ba5c2197163832e323bb4a4da26a4c2cb14cb2ad492b7
7
- data.tar.gz: 78c2f26bf97d4f70fe7f72ef3e8fd1d2c297bac241da5e43cefbb23f221eb2e934179937dd858f695be4bcc5761fbf869b4e48e71bde607e94541df38e93e496
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 file moved to done/ folder")
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
- Dir[ForemanInventoryUpload.uploads_file_path(filename), ForemanInventoryUpload.done_file_path(filename)]
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
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '12.2.17'.freeze
2
+ VERSION = '12.2.18'.freeze
3
3
  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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "12.2.17",
3
+ "version": "12.2.18",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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
 
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_rh_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 12.2.17
4
+ version: 12.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team