foreman_rh_cloud 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +619 -0
- data/README.md +38 -0
- data/Rakefile +47 -0
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +39 -0
- data/app/controllers/foreman_inventory_upload/react_controller.rb +7 -0
- data/app/controllers/foreman_inventory_upload/reports_controller.rb +30 -0
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +31 -0
- data/app/helpers/foreman_inventory_upload_helper.rb +13 -0
- data/app/views/foreman_inventory_upload/layouts/react.html.erb +16 -0
- data/config/routes.rb +10 -0
- data/lib/foreman_inventory_upload.rb +51 -0
- data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +19 -0
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +37 -0
- data/lib/foreman_inventory_upload/async/progress_output.rb +61 -0
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +47 -0
- data/lib/foreman_inventory_upload/async/shell_process.rb +36 -0
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +58 -0
- data/lib/foreman_inventory_upload/generators/archived_report.rb +53 -0
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +18 -0
- data/lib/foreman_inventory_upload/generators/json_stream.rb +55 -0
- data/lib/foreman_inventory_upload/generators/metadata.rb +36 -0
- data/lib/foreman_inventory_upload/generators/queries.rb +61 -0
- data/lib/foreman_inventory_upload/generators/slice.rb +147 -0
- data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +44 -0
- data/lib/foreman_rh_cloud.rb +4 -0
- data/lib/foreman_rh_cloud/engine.rb +62 -0
- data/lib/foreman_rh_cloud/version.rb +3 -0
- data/lib/tasks/foreman_rh_cloud_tasks.rake +37 -0
- data/lib/tasks/generator.rake +29 -0
- data/locale/Makefile +60 -0
- data/locale/en/foreman_rh_cloud.po +19 -0
- data/locale/foreman_rh_cloud.pot +19 -0
- data/locale/gemspec.rb +2 -0
- data/package.json +125 -0
- data/test/controllers/accounts_controller_test.rb +25 -0
- data/test/controllers/reports_controller_test.rb +21 -0
- data/test/controllers/uploads_controller_test.rb +21 -0
- data/test/factories/inventory_upload_factories.rb +88 -0
- data/test/test_plugin_helper.rb +26 -0
- data/test/unit/archived_report_generator_test.rb +61 -0
- data/test/unit/metadata_generator_test.rb +40 -0
- data/test/unit/shell_process_job_test.rb +27 -0
- data/test/unit/slice_generator_test.rb +177 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +37 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +74 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +65 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListConstants.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +55 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +8 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.js +16 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyStateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +26 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/emptyState.scss +7 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.js +23 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorStateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +20 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss +18 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +41 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItemHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +50 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.fixtures.js +7 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +43 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +29 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +78 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +16 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +20 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +60 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +26 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +44 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +47 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +69 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +46 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +9 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +27 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +50 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +145 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js +19 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +87 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardConstants.js +9 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js +68 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +17 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +25 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +39 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +16 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +64 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +45 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/Dashboard.test.js.snap +35 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardActions.test.js.snap +76 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardReducer.test.js.snap +44 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardSelectors.test.js.snap +42 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/dashboard.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/index.js +34 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +22 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownloadHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss +3 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +50 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModalHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +64 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +18 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +10 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.js +83 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainerHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +26 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +89 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/navContainer.scss +7 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +16 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +57 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/__snapshots__/ReportGenerate.test.js.snap +45 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/reportGenerate.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +18 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +53 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUploadHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/__snapshots__/ReportUpload.test.js.snap +45 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/reportUpload.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js +3 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js +27 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRunHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +14 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +25 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/scheduledRun.scss +11 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +56 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChartHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +74 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss +8 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.js +31 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBodyHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +19 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +3 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.js +24 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainerHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +18 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +8 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.js +19 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooterHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +12 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/tabFooter.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +47 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeaderHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +13 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/__snapshots__/TabHeader.test.js.snap +43 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss +21 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.fixtures.js +10 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +112 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/TerminalHelper.js +6 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +35 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +98 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/index.js +1 -0
- data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +31 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +15 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.test.js +10 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +12 -0
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +4 -0
- data/webpack/ForemanInventoryUpload/__snapshots__/ForemanInventoryUpload.test.js.snap +16 -0
- data/webpack/ForemanInventoryUpload/index.js +1 -0
- data/webpack/__mocks__/foremanReact/API.js +7 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +5 -0
- data/webpack/__mocks__/foremanReact/common/helpers.js +3 -0
- data/webpack/index.js +18 -0
- data/webpack/stories/ForemanInventoryUploadReducers.js +3 -0
- data/webpack/stories/configureStore.js +15 -0
- data/webpack/stories/decorators/index.js +1 -0
- data/webpack/stories/decorators/withCardsDecorator.js +14 -0
- data/webpack/stories/index.js +10 -0
- data/webpack/stories/index.scss +7 -0
- data/webpack/test_setup.js +6 -0
- metadata +318 -0
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# ForemanRhCloud
|
2
|
+
|
3
|
+
*Introdction here*
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
See [How_to_Install_a_Plugin](http://projects.theforeman.org/projects/foreman/wiki/How_to_Install_a_Plugin)
|
8
|
+
for how to install Foreman plugins
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
*Usage here*
|
13
|
+
|
14
|
+
## TODO
|
15
|
+
|
16
|
+
*Todo list here*
|
17
|
+
|
18
|
+
## Contributing
|
19
|
+
|
20
|
+
Fork and send a Pull Request. Thanks!
|
21
|
+
|
22
|
+
## Copyright
|
23
|
+
|
24
|
+
Copyright (c) *year* *your name*
|
25
|
+
|
26
|
+
This program is free software: you can redistribute it and/or modify
|
27
|
+
it under the terms of the GNU General Public License as published by
|
28
|
+
the Free Software Foundation, either version 3 of the License, or
|
29
|
+
(at your option) any later version.
|
30
|
+
|
31
|
+
This program is distributed in the hope that it will be useful,
|
32
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
33
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
34
|
+
GNU General Public License for more details.
|
35
|
+
|
36
|
+
You should have received a copy of the GNU General Public License
|
37
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
38
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'ForemanRhCloud'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
task default: :test
|
37
|
+
|
38
|
+
begin
|
39
|
+
require 'rubocop/rake_task'
|
40
|
+
RuboCop::RakeTask.new
|
41
|
+
rescue => _
|
42
|
+
puts 'Rubocop not loaded.'
|
43
|
+
end
|
44
|
+
|
45
|
+
task :default do
|
46
|
+
Rake::Task['rubocop'].execute
|
47
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
class AccountsController < ::ApplicationController
|
3
|
+
# override default "welcome screen behavior, since we don't have a model"
|
4
|
+
def welcome
|
5
|
+
true
|
6
|
+
end
|
7
|
+
|
8
|
+
def index
|
9
|
+
labels = Organization.all.pluck(:id, :name)
|
10
|
+
|
11
|
+
accounts = Hash[
|
12
|
+
labels.map do |id, label|
|
13
|
+
generate_report_status = status_for(id, ForemanInventoryUpload::Async::GenerateReportJob)
|
14
|
+
upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportJob)
|
15
|
+
|
16
|
+
[
|
17
|
+
id,
|
18
|
+
{
|
19
|
+
generate_report_status: generate_report_status,
|
20
|
+
upload_report_status: upload_report_status,
|
21
|
+
label: label,
|
22
|
+
},
|
23
|
+
]
|
24
|
+
end
|
25
|
+
]
|
26
|
+
|
27
|
+
render json: {
|
28
|
+
accounts: accounts,
|
29
|
+
}, status: :ok
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def status_for(label, job_class)
|
35
|
+
label = job_class.output_label(label)
|
36
|
+
ForemanInventoryUpload::Async::ProgressOutput.get(label)&.status
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanInventoryUpload
|
4
|
+
class ReportsController < ::ApplicationController
|
5
|
+
def last
|
6
|
+
label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(params[:organization_id])
|
7
|
+
output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
|
8
|
+
task_label = ForemanInventoryUpload::Async::GenerateAllReportsJob.singleton_job_name
|
9
|
+
scheduled = ForemanTasks::Task.where(
|
10
|
+
:label => task_label,
|
11
|
+
:state => 'scheduled'
|
12
|
+
).first&.start_at || nil
|
13
|
+
|
14
|
+
render json: {
|
15
|
+
output: output,
|
16
|
+
scheduled: scheduled,
|
17
|
+
}, status: :ok
|
18
|
+
end
|
19
|
+
|
20
|
+
def generate
|
21
|
+
organization_id = params[:organization_id]
|
22
|
+
|
23
|
+
ForemanInventoryUpload::Async::GenerateReportJob.perform_later(ForemanInventoryUpload.generated_reports_folder, organization_id)
|
24
|
+
|
25
|
+
render json: {
|
26
|
+
action_status: 'success',
|
27
|
+
}, status: :ok
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
class UploadsController < ::ApplicationController
|
3
|
+
def last
|
4
|
+
label = ForemanInventoryUpload::Async::UploadReportJob.output_label(params[:organization_id])
|
5
|
+
output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
|
6
|
+
|
7
|
+
render json: {
|
8
|
+
output: output,
|
9
|
+
}, status: :ok
|
10
|
+
end
|
11
|
+
|
12
|
+
def download_file
|
13
|
+
filename = ForemanInventoryUpload.facts_archive_name(params[:organization_id])
|
14
|
+
path = Rails.root.join(ForemanInventoryUpload.uploads_folder, filename)
|
15
|
+
unless File.exist? path
|
16
|
+
return throw_flash_error(
|
17
|
+
"Path doesn't exist: #{path}"
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
send_file path, disposition: 'attachment', filename: filename
|
22
|
+
end
|
23
|
+
|
24
|
+
def throw_flash_error(message)
|
25
|
+
process_error(
|
26
|
+
:redirect => foreman_inventory_upload_index_path,
|
27
|
+
:error_msg => message
|
28
|
+
)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ForemanInventoryUploadHelper
|
2
|
+
if Foreman::Version.new.minor.to_i < 23
|
3
|
+
def webpacked_plugins_css_for(*plugin_names)
|
4
|
+
css_tags_for(select_requested_plugins(plugin_names)).join.html_safe
|
5
|
+
end
|
6
|
+
|
7
|
+
def css_tags_for(requested_plugins)
|
8
|
+
requested_plugins.map do |plugin|
|
9
|
+
stylesheet_link_tag(*webpack_asset_paths(plugin.to_s, :extension => 'css'), "data-turbolinks-track" => true)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<% content_for(:javascripts) do %>
|
2
|
+
<%= webpacked_plugins_js_for :'foreman_rh_cloud' %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<% content_for(:stylesheets) do %>
|
6
|
+
<%= webpacked_plugins_css_for :'foreman_rh_cloud' %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% content_for(:content) do %>
|
10
|
+
<%= notifications %>
|
11
|
+
<div id="organization-id" data-id="<%= Organization.current.id if Organization.current %>" ></div>
|
12
|
+
<div id="user-id" data-id="<%= User.current.id if User.current %>" ></div>
|
13
|
+
<div id="ForemanInventoryUploadReactRoot"></div>
|
14
|
+
<% end %>
|
15
|
+
<%= render file: "layouts/base" %>
|
16
|
+
<%= mount_react_component('ForemanInventoryUpload', '#ForemanInventoryUploadReactRoot') %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
namespace :foreman_inventory_upload do
|
3
|
+
get 'index', to: 'react#index'
|
4
|
+
get ':organization_id/reports/last', to: 'reports#last', constraints: { organization_id: %r{[^\/]+} }
|
5
|
+
post ':organization_id/reports', to: 'reports#generate', constraints: { organization_id: %r{[^\/]+} }
|
6
|
+
get ':organization_id/uploads/last', to: 'uploads#last', constraints: { organization_id: %r{[^\/]+} }
|
7
|
+
get ':organization_id/uploads/file', to: 'uploads#download_file', constraints: { organization_id: %r{[^\/]+} }
|
8
|
+
get 'accounts', to: 'accounts#index'
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
def self.base_folder
|
3
|
+
# in production setup, where selinux is enabled, we only have rights to
|
4
|
+
# create folders under /ver/lib/foreman. If the folder does not exist, it's
|
5
|
+
# a dev setup, where we can use our current root
|
6
|
+
@base_folder ||= File.join(
|
7
|
+
Dir.glob('/var/lib/foreman').first || Dir.getwd,
|
8
|
+
'red_hat_inventory/'
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.uploads_folder
|
13
|
+
@uploads_folder ||= ensure_folder(
|
14
|
+
File.join(
|
15
|
+
ForemanInventoryUpload.base_folder,
|
16
|
+
'uploads/'
|
17
|
+
)
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.generated_reports_folder
|
22
|
+
@generated_reports_folder ||= ensure_folder(
|
23
|
+
File.join(
|
24
|
+
ForemanInventoryUpload.base_folder,
|
25
|
+
'generated_reports/'
|
26
|
+
)
|
27
|
+
)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.outputs_folder
|
31
|
+
@outputs_folder ||= ensure_folder(File.join(ForemanInventoryUpload.base_folder, 'outputs/'))
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.upload_script_file
|
35
|
+
'uploader.sh'
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.facts_archive_name(organization)
|
39
|
+
"report_for_#{organization}.tar.gz"
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.upload_url
|
43
|
+
# for testing set ENV to 'https://ci.cloud.redhat.com/api/ingress/v1/upload'
|
44
|
+
@upload_url ||= ENV['SATELLITE_INVENTORY_UPLOAD_URL'] || 'https://cert.cloud.redhat.com/api/ingress/v1/upload'
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.ensure_folder(folder)
|
48
|
+
FileUtils.mkdir_p(folder)
|
49
|
+
folder
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
module Async
|
3
|
+
class GenerateAllReportsJob < ::ApplicationJob
|
4
|
+
def perform
|
5
|
+
organizations = Organization.unscoped.all
|
6
|
+
|
7
|
+
organizations.map do |organization|
|
8
|
+
GenerateReportJob.perform_later(ForemanInventoryUpload.generated_reports_folder, organization.id)
|
9
|
+
end
|
10
|
+
ensure
|
11
|
+
self.class.set(:wait => 24.hours).perform_later
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.singleton_job_name
|
15
|
+
name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
module Async
|
3
|
+
class GenerateReportJob < ShellProcess
|
4
|
+
def self.output_label(label)
|
5
|
+
"report_for_#{label}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def perform(base_folder, organization)
|
9
|
+
@base_folder = base_folder
|
10
|
+
@organization = organization
|
11
|
+
|
12
|
+
super(GenerateReportJob.output_label(organization))
|
13
|
+
|
14
|
+
QueueForUploadJob.perform_later(
|
15
|
+
base_folder,
|
16
|
+
ForemanInventoryUpload.facts_archive_name(organization),
|
17
|
+
organization
|
18
|
+
)
|
19
|
+
end
|
20
|
+
|
21
|
+
def rake_prefix
|
22
|
+
'foreman-' unless Rails.env.development?
|
23
|
+
end
|
24
|
+
|
25
|
+
def command
|
26
|
+
"#{rake_prefix}rake foreman_inventory_upload:report:generate"
|
27
|
+
end
|
28
|
+
|
29
|
+
def env
|
30
|
+
super.merge(
|
31
|
+
'target' => @base_folder,
|
32
|
+
'organization_id' => @organization
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
module Async
|
3
|
+
class ProgressOutput
|
4
|
+
def self.get(label)
|
5
|
+
ProgressOutput.new(label, :reader)
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.register(label)
|
9
|
+
ProgressOutput.new(label, :writer)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(label, mode)
|
13
|
+
@label = label
|
14
|
+
@mode = mode
|
15
|
+
end
|
16
|
+
|
17
|
+
def buffer
|
18
|
+
@buffer ||= begin
|
19
|
+
File.open(file_name, file_mode)
|
20
|
+
rescue Errno::ENOENT
|
21
|
+
StringIO.new
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def full_output
|
26
|
+
buffer.read
|
27
|
+
end
|
28
|
+
|
29
|
+
def write_line(line)
|
30
|
+
buffer << line
|
31
|
+
buffer.fsync
|
32
|
+
end
|
33
|
+
|
34
|
+
def close
|
35
|
+
@buffer&.close
|
36
|
+
end
|
37
|
+
|
38
|
+
def status
|
39
|
+
File.read(file_name(:status))
|
40
|
+
rescue Errno::ENOENT
|
41
|
+
''
|
42
|
+
end
|
43
|
+
|
44
|
+
def status=(status)
|
45
|
+
File.atomic_write(file_name(:status)) do |status_file|
|
46
|
+
status_file.write(status)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def file_mode
|
53
|
+
(@mode == :reader) ? 'r' : 'w'
|
54
|
+
end
|
55
|
+
|
56
|
+
def file_name(type = 'out')
|
57
|
+
File.join(ForemanInventoryUpload.outputs_folder, "#{@label}.#{type}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
module Async
|
3
|
+
class QueueForUploadJob < ::ApplicationJob
|
4
|
+
def perform(base_folder, report_file, organization_id)
|
5
|
+
@base_folder = base_folder
|
6
|
+
@report_file = report_file
|
7
|
+
logger.debug('Ensuring objects')
|
8
|
+
ensure_ouput_folder
|
9
|
+
ensure_output_script
|
10
|
+
logger.debug("Copying #{report_file} to #{uploads_folder}")
|
11
|
+
enqueued_file_name = File.join(uploads_folder, report_file)
|
12
|
+
FileUtils.mv(File.join(base_folder, report_file), enqueued_file_name)
|
13
|
+
logger.debug("Done copying #{report_file} to #{enqueued_file_name}")
|
14
|
+
|
15
|
+
UploadReportJob.perform_later(enqueued_file_name, organization_id)
|
16
|
+
end
|
17
|
+
|
18
|
+
def uploads_folder
|
19
|
+
@uploads_folder ||= ForemanInventoryUpload.uploads_folder
|
20
|
+
end
|
21
|
+
|
22
|
+
def script_file
|
23
|
+
@script_file ||= File.join(uploads_folder, ForemanInventoryUpload.upload_script_file)
|
24
|
+
end
|
25
|
+
|
26
|
+
def ensure_ouput_folder
|
27
|
+
FileUtils.mkdir_p(uploads_folder)
|
28
|
+
end
|
29
|
+
|
30
|
+
def ensure_output_script
|
31
|
+
return if File.exist?(script_file)
|
32
|
+
|
33
|
+
script_source_file = File.join(ForemanRhCloud::Engine.root, 'lib/foreman_inventory_upload/scripts/uploader.sh.erb')
|
34
|
+
|
35
|
+
script_source = File.read(script_source_file)
|
36
|
+
script_source.gsub!('<%= @upload_url %>', ForemanInventoryUpload.upload_url)
|
37
|
+
|
38
|
+
File.write(script_file, script_source)
|
39
|
+
FileUtils.chmod('+x', script_file)
|
40
|
+
end
|
41
|
+
|
42
|
+
def logger
|
43
|
+
Foreman::Logging.logger('background')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|