foreman_inventory_upload 0.9.2 → 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/controllers/foreman_inventory_upload/reports_controller.rb +4 -3
- data/app/controllers/foreman_inventory_upload/statuses_controller.rb +41 -0
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +3 -3
- data/app/views/scripts/uploader.sh.erb +12 -25
- data/config/routes.rb +5 -5
- data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +7 -4
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +10 -18
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +17 -12
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +17 -22
- data/lib/foreman_inventory_upload/engine.rb +0 -2
- data/lib/foreman_inventory_upload/generators/archived_report.rb +2 -2
- data/lib/foreman_inventory_upload/generators/queries.rb +10 -19
- data/lib/foreman_inventory_upload/generators/slice.rb +3 -24
- data/lib/foreman_inventory_upload/version.rb +1 -1
- data/lib/foreman_inventory_upload.rb +10 -15
- data/lib/tasks/foreman_inventory_upload_tasks.rake +1 -1
- data/lib/tasks/generator.rake +5 -19
- data/test/controllers/reports_controller_test.rb +3 -3
- data/test/controllers/{accounts_controller_test.rb → statuses_controller_test.rb} +7 -6
- data/test/controllers/uploads_controller_test.rb +3 -3
- data/test/unit/archived_report_generator_test.rb +3 -3
- data/test/unit/slice_generator_test.rb +0 -74
- metadata +41 -180
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +0 -39
- data/package.json +0 -125
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +0 -37
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +0 -74
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js +0 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +0 -65
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListConstants.js +0 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +0 -55
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +0 -8
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.js +0 -16
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyStateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +0 -26
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/emptyState.scss +0 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.js +0 -23
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorStateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +0 -20
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss +0 -18
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +0 -41
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItemHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +0 -50
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.fixtures.js +0 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +0 -43
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +0 -29
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +0 -78
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +0 -16
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +0 -20
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +0 -60
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +0 -26
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +0 -44
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +0 -47
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +0 -69
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +0 -46
- data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +0 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +0 -27
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +0 -50
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +0 -146
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js +0 -19
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +0 -87
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardConstants.js +0 -9
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js +0 -68
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +0 -17
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +0 -25
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +0 -39
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +0 -16
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +0 -64
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +0 -45
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/Dashboard.test.js.snap +0 -36
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardActions.test.js.snap +0 -76
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardReducer.test.js.snap +0 -44
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardSelectors.test.js.snap +0 -42
- data/webpack/ForemanInventoryUpload/Components/Dashboard/dashboard.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/Dashboard/index.js +0 -34
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +0 -22
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownloadHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +0 -25
- data/webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss +0 -3
- data/webpack/ForemanInventoryUpload/Components/FileDownload/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +0 -50
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModalHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +0 -64
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +0 -10
- data/webpack/ForemanInventoryUpload/Components/FullScreenModal/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +0 -10
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.js +0 -83
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainerHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +0 -26
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +0 -89
- data/webpack/ForemanInventoryUpload/Components/NavContainer/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/NavContainer/navContainer.scss +0 -7
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +0 -16
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +0 -57
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerateHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/__snapshots__/ReportGenerate.test.js.snap +0 -45
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/reportGenerate.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +0 -18
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +0 -57
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUploadHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/__snapshots__/ReportUpload.test.js.snap +0 -45
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/reportUpload.scss +0 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js +0 -3
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js +0 -27
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRunHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +0 -14
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +0 -25
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/ScheduledRun/scheduledRun.scss +0 -11
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +0 -56
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChartHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +0 -74
- data/webpack/ForemanInventoryUpload/Components/StatusChart/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss +0 -8
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.js +0 -31
- data/webpack/ForemanInventoryUpload/Components/TabBody/TabBodyHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +0 -19
- data/webpack/ForemanInventoryUpload/Components/TabBody/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +0 -3
- data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.js +0 -24
- data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainerHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +0 -18
- data/webpack/ForemanInventoryUpload/Components/TabContainer/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +0 -8
- data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.fixtures.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.js +0 -19
- data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooterHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +0 -12
- data/webpack/ForemanInventoryUpload/Components/TabFooter/index.js +0 -1
- 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 +0 -45
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeaderHelper.js +0 -0
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/__snapshots__/TabHeader.test.js.snap +0 -53
- data/webpack/ForemanInventoryUpload/Components/TabHeader/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss +0 -21
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.fixtures.js +0 -10
- data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +0 -112
- data/webpack/ForemanInventoryUpload/Components/Terminal/TerminalHelper.js +0 -6
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +0 -35
- data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +0 -98
- data/webpack/ForemanInventoryUpload/Components/Terminal/index.js +0 -1
- data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +0 -31
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +0 -15
- data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.test.js +0 -10
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +0 -12
- data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +0 -4
- data/webpack/ForemanInventoryUpload/__snapshots__/ForemanInventoryUpload.test.js.snap +0 -16
- data/webpack/ForemanInventoryUpload/index.js +0 -1
- data/webpack/__mocks__/foremanReact/API.js +0 -7
- data/webpack/__mocks__/foremanReact/common/I18n.js +0 -5
- data/webpack/__mocks__/foremanReact/common/helpers.js +0 -3
- data/webpack/index.js +0 -18
- data/webpack/stories/ForemanInventoryUploadReducers.js +0 -3
- data/webpack/stories/configureStore.js +0 -15
- data/webpack/stories/decorators/index.js +0 -1
- data/webpack/stories/decorators/withCardsDecorator.js +0 -14
- data/webpack/stories/index.js +0 -10
- data/webpack/stories/index.scss +0 -7
- data/webpack/test_setup.js +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 64394cf6cba5b7e8c903f1b54269cd944e970ed6
|
4
|
+
data.tar.gz: 2cf1d64dc23506fc1e2808d0ee283cff9010b33e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16db4189b92eeafd639a0a67fe1bdae2d4d5be7931cc6ab43ea4a2fa3b8d9e88365c7d1757a205d8c23718b97c7da7bb28849d6c17f731ba27f5a8d42c5719af
|
7
|
+
data.tar.gz: 7ee617fe1bb503bcae3f82a5c74cd3d25266afee0d7f731a8ba4e6b4ca3a15c6d70f5b39e21b49f607867f7bdc3d40cbf549ae7e1062ef327da1419601ee2012
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module ForemanInventoryUpload
|
4
4
|
class ReportsController < ::ApplicationController
|
5
5
|
def last
|
6
|
-
label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(params[:
|
6
|
+
label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(params[:portal_user])
|
7
7
|
output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
|
8
8
|
task_label = ForemanInventoryUpload::Async::GenerateAllReportsJob.singleton_job_name
|
9
9
|
scheduled = ForemanTasks::Task.where(
|
@@ -18,9 +18,10 @@ module ForemanInventoryUpload
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def generate
|
21
|
-
|
21
|
+
portal_user = params[:portal_user]
|
22
22
|
|
23
|
-
|
23
|
+
generated_file_name = File.join(ForemanInventoryUpload.base_folder, "#{portal_user}.tar.gz")
|
24
|
+
ForemanInventoryUpload::Async::GenerateReportJob.perform_later(generated_file_name, portal_user)
|
24
25
|
|
25
26
|
render json: {
|
26
27
|
action_status: 'success',
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
class StatusesController < ::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
|
+
portal_users = RedhatAccess::TelemetryConfiguration
|
10
|
+
.where(enable_telemetry: true)
|
11
|
+
.distinct
|
12
|
+
.pluck(:portal_user)
|
13
|
+
|
14
|
+
statuses = Hash[
|
15
|
+
portal_users.map do |portal_user|
|
16
|
+
generate_report_status = status_for(portal_user, ForemanInventoryUpload::Async::GenerateReportJob)
|
17
|
+
upload_report_status = status_for(portal_user, ForemanInventoryUpload::Async::UploadReportJob)
|
18
|
+
|
19
|
+
[
|
20
|
+
portal_user,
|
21
|
+
{
|
22
|
+
generate_report_status: generate_report_status,
|
23
|
+
upload_report_status: upload_report_status,
|
24
|
+
},
|
25
|
+
]
|
26
|
+
end
|
27
|
+
]
|
28
|
+
|
29
|
+
render json: {
|
30
|
+
statuses: statuses,
|
31
|
+
}, status: :ok
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def status_for(portal_user, job_class)
|
37
|
+
label = job_class.output_label(portal_user)
|
38
|
+
ForemanInventoryUpload::Async::ProgressOutput.get(label)&.status
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ForemanInventoryUpload
|
2
2
|
class UploadsController < ::ApplicationController
|
3
3
|
def last
|
4
|
-
label = ForemanInventoryUpload::Async::UploadReportJob.output_label(params[:
|
4
|
+
label = ForemanInventoryUpload::Async::UploadReportJob.output_label(params[:portal_user])
|
5
5
|
output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
|
6
6
|
|
7
7
|
render json: {
|
@@ -10,8 +10,8 @@ module ForemanInventoryUpload
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def download_file
|
13
|
-
filename =
|
14
|
-
path = Rails.root.join(ForemanInventoryUpload.uploads_folder, filename)
|
13
|
+
filename = 'hosts_report.tar.gz'
|
14
|
+
path = Rails.root.join(ForemanInventoryUpload.uploads_folder(params[:portal_user]), filename)
|
15
15
|
unless File.exist? path
|
16
16
|
return throw_flash_error(
|
17
17
|
"Path doesn't exist: #{path}"
|
@@ -1,43 +1,30 @@
|
|
1
1
|
#! /bin/sh
|
2
2
|
|
3
3
|
DEST=<%= @upload_url %>
|
4
|
+
RH_USERNAME=<%= @rh_username %>
|
4
5
|
|
5
|
-
if [ -z "$
|
6
|
+
if [ -z "$RH_USERNAME" ]
|
6
7
|
then
|
7
|
-
|
8
|
+
IFS= read -rp "Enter username: " RH_USERNAME
|
8
9
|
fi
|
9
10
|
|
10
|
-
if [ -
|
11
|
+
if [ -z "$RH_PASSWORD" ]
|
11
12
|
then
|
12
|
-
|
13
|
-
AUTH_VAL="$CER_PATH"
|
14
|
-
else
|
15
|
-
if [ -z "$RH_USERNAME" ]
|
16
|
-
then
|
17
|
-
IFS= read -rp "Enter username: " RH_USERNAME
|
18
|
-
fi
|
19
|
-
|
20
|
-
if [ -z "$RH_PASSWORD" ]
|
21
|
-
then
|
22
|
-
IFS= read -rsp "Enter password: " RH_PASSWORD
|
23
|
-
fi
|
24
|
-
|
25
|
-
AUTH_KEY="-u"
|
26
|
-
AUTH_VAL="\"$RH_USERNAME\":\"$RH_PASSWORD\""
|
13
|
+
IFS= read -rsp "Enter password: " RH_PASSWORD
|
27
14
|
fi
|
28
15
|
|
29
|
-
|
30
|
-
|
16
|
+
if [ -z "$FILES" ]
|
17
|
+
then
|
18
|
+
FILES=./*.tar.gz
|
19
|
+
fi
|
31
20
|
|
32
|
-
|
33
|
-
DONE_DIR="$SCRIPT_DIR/done/"
|
34
|
-
mkdir -p $DONE_DIR
|
21
|
+
mkdir -p done
|
35
22
|
|
36
23
|
for f in $FILES
|
37
24
|
do
|
38
|
-
curl -k -vvv -# --fail -F "file=@$f;type=application/vnd.redhat.qpc.tar+tgz" $DEST "$
|
25
|
+
curl -k -vvv -# --fail -F "file=@$f;type=application/vnd.redhat.qpc.tar+tgz" $DEST -u "$RH_USERNAME":"$RH_PASSWORD"
|
39
26
|
if [ $? -eq 0 ]; then
|
40
|
-
mv $f
|
27
|
+
mv $f done/
|
41
28
|
echo "Done: $f"
|
42
29
|
fi
|
43
30
|
done
|
data/config/routes.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
namespace :foreman_inventory_upload do
|
3
3
|
get 'index', to: 'react#index'
|
4
|
-
get ':
|
5
|
-
post ':
|
6
|
-
get ':
|
7
|
-
get ':
|
8
|
-
get '
|
4
|
+
get ':portal_user/reports/last', to: 'reports#last', constraints: { portal_user: %r{[^\/]+} }
|
5
|
+
post ':portal_user/reports', to: 'reports#generate', constraints: { portal_user: %r{[^\/]+} }
|
6
|
+
get ':portal_user/uploads/last', to: 'uploads#last', constraints: { portal_user: %r{[^\/]+} }
|
7
|
+
get ':portal_user/uploads/file', to: 'uploads#download_file', constraints: { portal_user: %r{[^\/]+} }
|
8
|
+
get 'statuses', to: 'statuses#index'
|
9
9
|
end
|
10
10
|
end
|
@@ -2,10 +2,13 @@ module ForemanInventoryUpload
|
|
2
2
|
module Async
|
3
3
|
class GenerateAllReportsJob < ::ApplicationJob
|
4
4
|
def perform
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
portal_users = RedhatAccess::TelemetryConfiguration
|
6
|
+
.where(enable_telemetry: true)
|
7
|
+
.distinct
|
8
|
+
.pluck(:portal_user)
|
9
|
+
portal_users.map do |portal_user|
|
10
|
+
generated_file_name = File.join(ForemanInventoryUpload.base_folder, "#{portal_user}.tar.gz")
|
11
|
+
GenerateReportJob.perform_later(generated_file_name, portal_user)
|
9
12
|
end
|
10
13
|
ensure
|
11
14
|
self.class.set(:wait => 24.hours).perform_later
|
@@ -1,35 +1,27 @@
|
|
1
1
|
module ForemanInventoryUpload
|
2
2
|
module Async
|
3
3
|
class GenerateReportJob < ShellProcess
|
4
|
-
def self.output_label(
|
5
|
-
"report_for_#{
|
4
|
+
def self.output_label(portal_user)
|
5
|
+
"report_for_#{portal_user}"
|
6
6
|
end
|
7
7
|
|
8
|
-
def perform(
|
9
|
-
@
|
10
|
-
@
|
8
|
+
def perform(result_file, portal_user)
|
9
|
+
@result_file = result_file
|
10
|
+
@portal_user = portal_user
|
11
11
|
|
12
|
-
super(GenerateReportJob.output_label(
|
12
|
+
super(GenerateReportJob.output_label(portal_user))
|
13
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?
|
14
|
+
QueueForUploadJob.perform_later(result_file, portal_user)
|
23
15
|
end
|
24
16
|
|
25
17
|
def command
|
26
|
-
|
18
|
+
'rake foreman_inventory_upload:report:generate'
|
27
19
|
end
|
28
20
|
|
29
21
|
def env
|
30
22
|
super.merge(
|
31
|
-
'target' => @
|
32
|
-
'
|
23
|
+
'target' => @result_file,
|
24
|
+
'portal_user' => @portal_user
|
33
25
|
)
|
34
26
|
end
|
35
27
|
end
|
@@ -1,22 +1,21 @@
|
|
1
1
|
module ForemanInventoryUpload
|
2
2
|
module Async
|
3
3
|
class QueueForUploadJob < ::ApplicationJob
|
4
|
-
def perform(
|
5
|
-
@
|
6
|
-
@report_file = report_file
|
4
|
+
def perform(report_file, portal_user)
|
5
|
+
@portal_user = portal_user
|
7
6
|
logger.debug('Ensuring objects')
|
8
7
|
ensure_ouput_folder
|
9
8
|
ensure_output_script
|
10
9
|
logger.debug("Copying #{report_file} to #{uploads_folder}")
|
11
|
-
enqueued_file_name = File.join(uploads_folder,
|
12
|
-
FileUtils.mv(
|
10
|
+
enqueued_file_name = File.join(uploads_folder, ForemanInventoryUpload.facts_archive_name)
|
11
|
+
FileUtils.mv(report_file, enqueued_file_name)
|
13
12
|
logger.debug("Done copying #{report_file} to #{enqueued_file_name}")
|
14
13
|
|
15
|
-
UploadReportJob.perform_later(enqueued_file_name,
|
14
|
+
UploadReportJob.perform_later(enqueued_file_name, portal_user)
|
16
15
|
end
|
17
16
|
|
18
17
|
def uploads_folder
|
19
|
-
@uploads_folder ||= ForemanInventoryUpload.uploads_folder
|
18
|
+
@uploads_folder ||= ForemanInventoryUpload.uploads_folder(@portal_user)
|
20
19
|
end
|
21
20
|
|
22
21
|
def script_file
|
@@ -30,11 +29,17 @@ module ForemanInventoryUpload
|
|
30
29
|
def ensure_output_script
|
31
30
|
return if File.exist?(script_file)
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
script_source = File.join(ForemanInventoryUpload::Engine.root, 'app/views/scripts/uploader.sh.erb')
|
33
|
+
|
34
|
+
template_src = Foreman::Renderer::Source::String.new(content: File.read(script_source))
|
35
|
+
scope = Foreman::Renderer::Scope::Base.new(
|
36
|
+
source: template_src,
|
37
|
+
variables: {
|
38
|
+
upload_url: ForemanInventoryUpload.upload_url,
|
39
|
+
rh_username: @portal_user,
|
40
|
+
}
|
41
|
+
)
|
42
|
+
script_source = Foreman::Renderer.render(template_src, scope)
|
38
43
|
File.write(script_file, script_source)
|
39
44
|
FileUtils.chmod('+x', script_file)
|
40
45
|
end
|
@@ -1,23 +1,15 @@
|
|
1
|
-
require 'tempfile'
|
2
|
-
|
3
1
|
module ForemanInventoryUpload
|
4
2
|
module Async
|
5
3
|
class UploadReportJob < ShellProcess
|
6
|
-
def self.output_label(
|
7
|
-
"upload_for_#{
|
4
|
+
def self.output_label(portal_user)
|
5
|
+
"upload_for_#{portal_user}"
|
8
6
|
end
|
9
7
|
|
10
|
-
def perform(filename,
|
8
|
+
def perform(filename, portal_user)
|
9
|
+
@portal_user = portal_user
|
11
10
|
@filename = filename
|
12
|
-
@organization = Organization.find(organization_id)
|
13
11
|
|
14
|
-
|
15
|
-
cer_file.write(rh_credentials[:cert])
|
16
|
-
cer_file.write(rh_credentials[:key])
|
17
|
-
cer_file.flush
|
18
|
-
@cer_path = cer_file.path
|
19
|
-
super(UploadReportJob.output_label(organization_id))
|
20
|
-
end
|
12
|
+
super(UploadReportJob.output_label(portal_user))
|
21
13
|
end
|
22
14
|
|
23
15
|
def command
|
@@ -26,19 +18,22 @@ module ForemanInventoryUpload
|
|
26
18
|
|
27
19
|
def env
|
28
20
|
super.merge(
|
29
|
-
'
|
30
|
-
'
|
21
|
+
'RH_USERNAME' => rh_username,
|
22
|
+
'RH_PASSWORD' => rh_password,
|
23
|
+
'FILES' => @filename
|
31
24
|
)
|
32
25
|
end
|
33
26
|
|
34
27
|
def rh_credentials
|
35
|
-
@rh_credentials ||=
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
28
|
+
@rh_credentials ||= RedhatAccess::TelemetryConfiguration.where(portal_user: @portal_user).last
|
29
|
+
end
|
30
|
+
|
31
|
+
def rh_username
|
32
|
+
@portal_user
|
33
|
+
end
|
34
|
+
|
35
|
+
def rh_password
|
36
|
+
rh_credentials.portal_password
|
42
37
|
end
|
43
38
|
end
|
44
39
|
end
|
@@ -11,8 +11,6 @@ module ForemanInventoryUpload
|
|
11
11
|
config.autoload_paths += Dir["#{config.root}/app/overrides"]
|
12
12
|
config.autoload_paths += Dir["#{config.root}/lib"]
|
13
13
|
|
14
|
-
config.eager_load_paths += Dir["#{config.root}/lib"]
|
15
|
-
|
16
14
|
# Add any db migrations
|
17
15
|
initializer 'foreman_inventory_upload.load_app_instance_data' do |app|
|
18
16
|
ForemanInventoryUpload::Engine.paths['db/migrate'].existent.each do |path|
|
@@ -6,10 +6,10 @@ module ForemanInventoryUpload
|
|
6
6
|
@logger = logger
|
7
7
|
end
|
8
8
|
|
9
|
-
def render(
|
9
|
+
def render(portal_user)
|
10
10
|
Dir.mktmpdir do |tmpdir|
|
11
11
|
@logger.info "Started generating hosts report in #{tmpdir}"
|
12
|
-
host_batches = ForemanInventoryUpload::Generators::Queries.
|
12
|
+
host_batches = ForemanInventoryUpload::Generators::Queries.for_report(portal_user)
|
13
13
|
File.open(File.join(tmpdir, 'metadata.json'), 'w') do |metadata_out|
|
14
14
|
metadata_generator = ForemanInventoryUpload::Generators::Metadata.new(metadata_out)
|
15
15
|
metadata_generator.render do |inner_generator|
|
@@ -17,7 +17,6 @@ module ForemanInventoryUpload
|
|
17
17
|
'distribution::name',
|
18
18
|
'uname::release',
|
19
19
|
'lscpu::flags',
|
20
|
-
'distribution::version',
|
21
20
|
]).pluck(:name, :id)
|
22
21
|
]
|
23
22
|
end
|
@@ -32,29 +31,21 @@ module ForemanInventoryUpload
|
|
32
31
|
:installed_packages,
|
33
32
|
:content_facet,
|
34
33
|
:host_statuses,
|
35
|
-
subscription_facet: [:pools, :installed_products
|
34
|
+
subscription_facet: [:pools, :installed_products]
|
36
35
|
)
|
37
36
|
.merge(fact_values)
|
38
37
|
end
|
39
38
|
|
40
39
|
def self.for_report(portal_user)
|
41
|
-
org_ids =
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
Organization
|
51
|
-
.joins(:telemetry_configuration)
|
52
|
-
.where(
|
53
|
-
redhat_access_telemetry_configurations: {
|
54
|
-
portal_user: portal_user,
|
55
|
-
enable_telemetry: true,
|
56
|
-
}
|
57
|
-
)
|
40
|
+
org_ids = Organization
|
41
|
+
.joins(:telemetry_configuration)
|
42
|
+
.where(
|
43
|
+
redhat_access_telemetry_configurations: {
|
44
|
+
portal_user: portal_user,
|
45
|
+
enable_telemetry: true,
|
46
|
+
}
|
47
|
+
).pluck(:id)
|
48
|
+
for_slice(Host.where(organization_id: org_ids)).in_batches(of: 1_000)
|
58
49
|
end
|
59
50
|
end
|
60
51
|
end
|
@@ -23,14 +23,14 @@ module ForemanInventoryUpload
|
|
23
23
|
first = true
|
24
24
|
hosts_batch.each do |host|
|
25
25
|
@stream.comma unless first
|
26
|
-
first = false
|
26
|
+
first = false
|
27
|
+
report_host(host)
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
32
33
|
def report_host(host)
|
33
|
-
return nil unless host&.subscription_facet&.pools&.first
|
34
34
|
@stream.object do
|
35
35
|
@stream.simple_field('display_name', host.name)
|
36
36
|
@stream.simple_field('fqdn', host.fqdn)
|
@@ -49,17 +49,9 @@ module ForemanInventoryUpload
|
|
49
49
|
@stream.stringify_value(nic.mac) if nic.mac
|
50
50
|
end.compact.join(', '))
|
51
51
|
end
|
52
|
-
@stream.object_field('system_profile') do
|
52
|
+
@stream.object_field('system_profile', :last) do
|
53
53
|
report_system_profile(host)
|
54
54
|
end
|
55
|
-
@stream.array_field('facts', :last) do
|
56
|
-
@stream.object do
|
57
|
-
@stream.simple_field('namespace', 'satellite')
|
58
|
-
@stream.object_field('facts', :last) do
|
59
|
-
report_satellite_facts(host)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
55
|
end
|
64
56
|
end
|
65
57
|
|
@@ -114,19 +106,6 @@ module ForemanInventoryUpload
|
|
114
106
|
end
|
115
107
|
end
|
116
108
|
|
117
|
-
def report_satellite_facts(host)
|
118
|
-
@stream.simple_field('virtual_host_name', host.subscription_facet.hypervisor_host&.name)
|
119
|
-
@stream.simple_field('virtual_host_uuid', host.subscription_facet.hypervisor_host&.subscription_facet&.uuid)
|
120
|
-
if defined?(ForemanThemeSatellite)
|
121
|
-
@stream.simple_field('satellite_version', ForemanThemeSatellite::SATELLITE_VERSION)
|
122
|
-
end
|
123
|
-
@stream.simple_field('system_purpose_usage', host.subscription_facet.purpose_usage)
|
124
|
-
@stream.simple_field('system_purpose_role', host.subscription_facet.purpose_role)
|
125
|
-
@stream.simple_field('distribution_version', fact_value(host, 'distribution::version'))
|
126
|
-
@stream.simple_field('satellite_instance_id', Foreman.respond_to?(:instance_id) ? Foreman.instance_id : nil)
|
127
|
-
@stream.simple_field('organization_id', host.organization_id, :last)
|
128
|
-
end
|
129
|
-
|
130
109
|
def fact_value(host, fact_name)
|
131
110
|
value_record = host.fact_values.find do |fact_value|
|
132
111
|
fact_value.fact_name_id == ForemanInventoryUpload::Generators::Queries.fact_names[fact_name]
|
@@ -11,20 +11,16 @@ module ForemanInventoryUpload
|
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.uploads_folder
|
15
|
-
@
|
16
|
-
|
17
|
-
|
18
|
-
'uploads/'
|
19
|
-
)
|
20
|
-
)
|
21
|
-
end
|
14
|
+
def self.uploads_folder(group)
|
15
|
+
@uploads_folders ||= {}
|
16
|
+
cache = @uploads_folders[group]
|
17
|
+
return cache if cache
|
22
18
|
|
23
|
-
|
24
|
-
@generated_reports_folder ||= ensure_folder(
|
19
|
+
@uploads_folders[group] = ensure_folder(
|
25
20
|
File.join(
|
26
21
|
ForemanInventoryUpload.base_folder,
|
27
|
-
'
|
22
|
+
'uploads/',
|
23
|
+
"#{group}/"
|
28
24
|
)
|
29
25
|
)
|
30
26
|
end
|
@@ -37,13 +33,12 @@ module ForemanInventoryUpload
|
|
37
33
|
'uploader.sh'
|
38
34
|
end
|
39
35
|
|
40
|
-
def self.facts_archive_name
|
41
|
-
|
36
|
+
def self.facts_archive_name
|
37
|
+
'hosts_report.tar.gz'
|
42
38
|
end
|
43
39
|
|
44
40
|
def self.upload_url
|
45
|
-
|
46
|
-
@upload_url ||= ENV['SATELLITE_INVENTORY_UPLOAD_URL'] || 'https://cert.cloud.redhat.com/api/ingress/v1/upload'
|
41
|
+
'https://ci.cloud.paas.psi.redhat.com/api/ingress/v1/upload'
|
47
42
|
end
|
48
43
|
|
49
44
|
def self.ensure_folder(folder)
|
data/lib/tasks/generator.rake
CHANGED
@@ -4,26 +4,12 @@ namespace :foreman_inventory_upload do
|
|
4
4
|
namespace :report do
|
5
5
|
desc 'Generate inventory report to be sent to Red Hat cloud'
|
6
6
|
task generate: :environment do
|
7
|
-
|
8
|
-
|
9
|
-
base_folder = ENV['target'] || Dir.pwd
|
7
|
+
target = ENV['target'] || ForemanInventoryUpload.facts_archive_name
|
8
|
+
portal_user = ENV['portal_user'] || 'anonymous'
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
if portal_user
|
16
|
-
puts "Generating report for all organizations associated with #{portal_user}"
|
17
|
-
base_folder = File.join(base_folder, portal_user)
|
18
|
-
organizations = ForemanInventoryUpload::Generators::Queries.organizations_for_user(portal_user).pluck(:id)
|
19
|
-
end
|
20
|
-
|
21
|
-
organizations.each do |organization|
|
22
|
-
target = File.join(base_folder, ForemanInventoryUpload.facts_archive_name(organization))
|
23
|
-
archived_report_generator = ForemanInventoryUpload::Generators::ArchivedReport.new(target, Logger.new(STDOUT))
|
24
|
-
archived_report_generator.render(organization: organization)
|
25
|
-
puts "Successfully generated #{target} for organization id #{organization}"
|
26
|
-
end
|
10
|
+
archived_report_generator = ForemanInventoryUpload::Generators::ArchivedReport.new(target, Logger.new(STDOUT))
|
11
|
+
archived_report_generator.render(portal_user)
|
12
|
+
puts "Successfully generated #{target} for #{portal_user}"
|
27
13
|
end
|
28
14
|
end
|
29
15
|
end
|
@@ -5,14 +5,14 @@ class ReportsControllerTest < ActionController::TestCase
|
|
5
5
|
|
6
6
|
test 'Returns latest report generation status' do
|
7
7
|
progress_output = mock('progress_output')
|
8
|
-
|
8
|
+
test_portal_user = 'test_portal_user'
|
9
9
|
ForemanInventoryUpload::Async::ProgressOutput
|
10
10
|
.expects(:get)
|
11
|
-
.with(ForemanInventoryUpload::Async::GenerateReportJob.output_label(
|
11
|
+
.with(ForemanInventoryUpload::Async::GenerateReportJob.output_label(test_portal_user))
|
12
12
|
.returns(progress_output)
|
13
13
|
progress_output.expects(:full_output).returns('test output')
|
14
14
|
|
15
|
-
get :last, params: {
|
15
|
+
get :last, params: { portal_user: test_portal_user }, session: set_session_user
|
16
16
|
|
17
17
|
assert_response :success
|
18
18
|
actual = JSON.parse(response.body)
|
@@ -1,24 +1,25 @@
|
|
1
1
|
require 'test_plugin_helper'
|
2
2
|
|
3
|
-
class
|
4
|
-
tests ForemanInventoryUpload::
|
3
|
+
class StatusesControllerTest < ActionController::TestCase
|
4
|
+
tests ForemanInventoryUpload::StatusesController
|
5
5
|
|
6
6
|
include FolderIsolation
|
7
7
|
|
8
8
|
test 'Returns statuses for each process type' do
|
9
|
-
|
9
|
+
configuration = RedhatAccess::TelemetryConfiguration.new(enable_telemetry: true, portal_user: 'test')
|
10
|
+
configuration.save!
|
10
11
|
|
11
|
-
generate_label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(
|
12
|
+
generate_label = ForemanInventoryUpload::Async::GenerateReportJob.output_label('test')
|
12
13
|
generate_output = ForemanInventoryUpload::Async::ProgressOutput.register(generate_label)
|
13
14
|
generate_output.status = 'generate_status_test'
|
14
|
-
upload_label = ForemanInventoryUpload::Async::UploadReportJob.output_label(
|
15
|
+
upload_label = ForemanInventoryUpload::Async::UploadReportJob.output_label('test')
|
15
16
|
upload_output = ForemanInventoryUpload::Async::ProgressOutput.register(upload_label)
|
16
17
|
upload_output.status = 'upload_status_test'
|
17
18
|
|
18
19
|
get :index, session: set_session_user
|
19
20
|
|
20
21
|
assert_response :success
|
21
|
-
actual = JSON.parse(response.body)['
|
22
|
+
actual = JSON.parse(response.body)['statuses']['test']
|
22
23
|
assert_equal 'generate_status_test', actual['generate_report_status']
|
23
24
|
assert_equal 'upload_status_test', actual['upload_report_status']
|
24
25
|
end
|
@@ -5,14 +5,14 @@ class UploadsControllerTest < ActionController::TestCase
|
|
5
5
|
|
6
6
|
test 'Returns latest upload status' do
|
7
7
|
progress_output = mock('progress_output')
|
8
|
-
|
8
|
+
test_portal_user = 'test_portal_user'
|
9
9
|
ForemanInventoryUpload::Async::ProgressOutput
|
10
10
|
.expects(:get)
|
11
|
-
.with(ForemanInventoryUpload::Async::UploadReportJob.output_label(
|
11
|
+
.with(ForemanInventoryUpload::Async::UploadReportJob.output_label(test_portal_user))
|
12
12
|
.returns(progress_output)
|
13
13
|
progress_output.expects(:full_output).returns('test output')
|
14
14
|
|
15
|
-
get :last, params: {
|
15
|
+
get :last, params: { portal_user: test_portal_user }, session: set_session_user
|
16
16
|
|
17
17
|
assert_response :success
|
18
18
|
actual = JSON.parse(response.body)
|