foreman_inventory_upload 0.0.1.dev1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +619 -0
  3. data/README.md +38 -0
  4. data/Rakefile +47 -0
  5. data/app/controllers/foreman_inventory_upload/react_controller.rb +7 -0
  6. data/app/controllers/foreman_inventory_upload/reports_controller.rb +23 -0
  7. data/app/controllers/foreman_inventory_upload/statuses_controller.rb +41 -0
  8. data/app/controllers/foreman_inventory_upload/uploads_controller.rb +31 -0
  9. data/app/helpers/foreman_inventory_upload_helper.rb +13 -0
  10. data/app/views/dashboard/_inventory_upload_widget.html.erb +2 -0
  11. data/app/views/foreman_inventory_upload/layouts/react.html.erb +16 -0
  12. data/app/views/scripts/uploader.sh.erb +31 -0
  13. data/config/routes.rb +10 -0
  14. data/lib/foreman_inventory_upload/async/generate_report_job.rb +29 -0
  15. data/lib/foreman_inventory_upload/async/progress_output.rb +61 -0
  16. data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +52 -0
  17. data/lib/foreman_inventory_upload/async/shell_process.rb +35 -0
  18. data/lib/foreman_inventory_upload/async/upload_report_job.rb +40 -0
  19. data/lib/foreman_inventory_upload/engine.rb +52 -0
  20. data/lib/foreman_inventory_upload/generators/archived_report.rb +53 -0
  21. data/lib/foreman_inventory_upload/generators/json_stream.rb +55 -0
  22. data/lib/foreman_inventory_upload/generators/metadata.rb +36 -0
  23. data/lib/foreman_inventory_upload/generators/queries.rb +52 -0
  24. data/lib/foreman_inventory_upload/generators/slice.rb +117 -0
  25. data/lib/foreman_inventory_upload/version.rb +3 -0
  26. data/lib/foreman_inventory_upload.rb +48 -0
  27. data/lib/tasks/foreman_inventory_upload_tasks.rake +37 -0
  28. data/lib/tasks/generator.rake +15 -0
  29. data/locale/Makefile +60 -0
  30. data/locale/en/foreman_yupana.po +19 -0
  31. data/locale/foreman_yupana.pot +19 -0
  32. data/locale/gemspec.rb +2 -0
  33. data/test/controllers/reports_controller_test.rb +21 -0
  34. data/test/controllers/statuses_controller_test.rb +26 -0
  35. data/test/controllers/uploads_controller_test.rb +21 -0
  36. data/test/factories/inventory_upload_factories.rb +88 -0
  37. data/test/test_plugin_helper.rb +26 -0
  38. data/test/unit/archived_report_generator_test.rb +61 -0
  39. data/test/unit/metadata_generator_test.rb +40 -0
  40. data/test/unit/shell_process_job_test.rb +27 -0
  41. data/test/unit/slice_generator_test.rb +60 -0
  42. metadata +149 -0
@@ -0,0 +1,27 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class ShellProcessJobTest < ActiveSupport::TestCase
4
+ class TestProcessJob < ForemanInventoryUpload::Async::ShellProcess
5
+ def command
6
+ 'echo testing env: $testenv'
7
+ end
8
+
9
+ def env
10
+ super.merge(
11
+ 'testenv' => 'test_val'
12
+ )
13
+ end
14
+ end
15
+
16
+ include FolderIsolation
17
+
18
+ test 'Runs a process with environment vars' do
19
+ label = Foreman.uuid
20
+ TestProcessJob.perform_now(label)
21
+
22
+ progress_output = ForemanInventoryUpload::Async::ProgressOutput.get(label)
23
+
24
+ assert_match(/test_val/, progress_output.full_output)
25
+ assert_match(/exit 0/, progress_output.status)
26
+ end
27
+ end
@@ -0,0 +1,60 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class ReportGeneratorTest < ActiveSupport::TestCase
4
+ setup do
5
+ User.current = User.find_by(login: 'secret_admin')
6
+
7
+ env = FactoryBot.create(:katello_k_t_environment)
8
+ cv = env.content_views << FactoryBot.create(:katello_content_view, organization: env.organization)
9
+
10
+ @host = FactoryBot.create(
11
+ :host,
12
+ :with_subscription,
13
+ :with_content,
14
+ content_view: cv.first,
15
+ lifecycle_environment: env,
16
+ organization: env.organization
17
+ )
18
+
19
+ @host.subscription_facet.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
20
+ end
21
+
22
+ def interesting_facts
23
+ [
24
+ 'dmi::system::uuid',
25
+ 'virt::uuid',
26
+ 'cpu::cpu(s)',
27
+ 'cpu::cpu_socket(s)',
28
+ 'cpu::core(s)_per_socket',
29
+ 'memory::memtotal',
30
+ 'dmi::bios::vendor',
31
+ 'dmi::bios::version',
32
+ 'dmi::bios::relase_date',
33
+ 'distribution::name',
34
+ 'uname::release',
35
+ 'lscpu::flags'
36
+ ]
37
+ end
38
+
39
+ def fact_names
40
+ @fact_names ||= Hash[
41
+ interesting_facts.map do |fact|
42
+ [fact, FactoryBot.create(:fact_name, name: fact, type: 'Katello::RhsmFactName')]
43
+ end
44
+ ]
45
+ end
46
+
47
+ test 'generates a report for a single host' do
48
+ batch = Host.where(id: @host.id).in_batches.first
49
+ generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
50
+
51
+ json_str = generator.render
52
+ actual = JSON.parse(json_str.join("\n"))
53
+
54
+ assert_equal 'slice_123', actual['report_slice_id']
55
+ assert_not_nil(actual_host = actual['hosts'].first)
56
+ assert_equal @host.name, actual_host['display_name']
57
+ assert_equal @host.fqdn, actual_host['fqdn']
58
+ assert_equal '1234', actual_host['account']
59
+ end
60
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: foreman_inventory_upload
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.dev1
5
+ platform: ruby
6
+ authors:
7
+ - Inventory upload team
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: katello
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: redhat_access
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Foreman plugin that process & upload data to cloud based host inventory
70
+ email:
71
+ - rlavi@redhat.com, sshtein@redhat.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - LICENSE
77
+ - README.md
78
+ - Rakefile
79
+ - app/controllers/foreman_inventory_upload/react_controller.rb
80
+ - app/controllers/foreman_inventory_upload/reports_controller.rb
81
+ - app/controllers/foreman_inventory_upload/statuses_controller.rb
82
+ - app/controllers/foreman_inventory_upload/uploads_controller.rb
83
+ - app/helpers/foreman_inventory_upload_helper.rb
84
+ - app/views/dashboard/_inventory_upload_widget.html.erb
85
+ - app/views/foreman_inventory_upload/layouts/react.html.erb
86
+ - app/views/scripts/uploader.sh.erb
87
+ - config/routes.rb
88
+ - lib/foreman_inventory_upload.rb
89
+ - lib/foreman_inventory_upload/async/generate_report_job.rb
90
+ - lib/foreman_inventory_upload/async/progress_output.rb
91
+ - lib/foreman_inventory_upload/async/queue_for_upload_job.rb
92
+ - lib/foreman_inventory_upload/async/shell_process.rb
93
+ - lib/foreman_inventory_upload/async/upload_report_job.rb
94
+ - lib/foreman_inventory_upload/engine.rb
95
+ - lib/foreman_inventory_upload/generators/archived_report.rb
96
+ - lib/foreman_inventory_upload/generators/json_stream.rb
97
+ - lib/foreman_inventory_upload/generators/metadata.rb
98
+ - lib/foreman_inventory_upload/generators/queries.rb
99
+ - lib/foreman_inventory_upload/generators/slice.rb
100
+ - lib/foreman_inventory_upload/version.rb
101
+ - lib/tasks/foreman_inventory_upload_tasks.rake
102
+ - lib/tasks/generator.rake
103
+ - locale/Makefile
104
+ - locale/en/foreman_yupana.po
105
+ - locale/foreman_yupana.pot
106
+ - locale/gemspec.rb
107
+ - test/controllers/reports_controller_test.rb
108
+ - test/controllers/statuses_controller_test.rb
109
+ - test/controllers/uploads_controller_test.rb
110
+ - test/factories/inventory_upload_factories.rb
111
+ - test/test_plugin_helper.rb
112
+ - test/unit/archived_report_generator_test.rb
113
+ - test/unit/metadata_generator_test.rb
114
+ - test/unit/shell_process_job_test.rb
115
+ - test/unit/slice_generator_test.rb
116
+ homepage: https://github.com/theforeman/foreman_inventory_upload
117
+ licenses:
118
+ - GPL-3.0
119
+ metadata: {}
120
+ post_install_message:
121
+ rdoc_options: []
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">"
132
+ - !ruby/object:Gem::Version
133
+ version: 1.3.1
134
+ requirements: []
135
+ rubyforge_project:
136
+ rubygems_version: 2.6.14
137
+ signing_key:
138
+ specification_version: 4
139
+ summary: Summary of ForemanInventoryUpload.
140
+ test_files:
141
+ - test/controllers/uploads_controller_test.rb
142
+ - test/controllers/statuses_controller_test.rb
143
+ - test/controllers/reports_controller_test.rb
144
+ - test/test_plugin_helper.rb
145
+ - test/factories/inventory_upload_factories.rb
146
+ - test/unit/shell_process_job_test.rb
147
+ - test/unit/metadata_generator_test.rb
148
+ - test/unit/archived_report_generator_test.rb
149
+ - test/unit/slice_generator_test.rb