foreman_rh_cloud 0.9.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) 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/accounts_controller.rb +39 -0
  6. data/app/controllers/foreman_inventory_upload/react_controller.rb +7 -0
  7. data/app/controllers/foreman_inventory_upload/reports_controller.rb +30 -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/foreman_inventory_upload/layouts/react.html.erb +16 -0
  11. data/config/routes.rb +10 -0
  12. data/lib/foreman_inventory_upload.rb +51 -0
  13. data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +19 -0
  14. data/lib/foreman_inventory_upload/async/generate_report_job.rb +37 -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 +47 -0
  17. data/lib/foreman_inventory_upload/async/shell_process.rb +36 -0
  18. data/lib/foreman_inventory_upload/async/upload_report_job.rb +58 -0
  19. data/lib/foreman_inventory_upload/generators/archived_report.rb +53 -0
  20. data/lib/foreman_inventory_upload/generators/fact_helpers.rb +18 -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 +61 -0
  24. data/lib/foreman_inventory_upload/generators/slice.rb +147 -0
  25. data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +44 -0
  26. data/lib/foreman_rh_cloud.rb +4 -0
  27. data/lib/foreman_rh_cloud/engine.rb +62 -0
  28. data/lib/foreman_rh_cloud/version.rb +3 -0
  29. data/lib/tasks/foreman_rh_cloud_tasks.rake +37 -0
  30. data/lib/tasks/generator.rake +29 -0
  31. data/locale/Makefile +60 -0
  32. data/locale/en/foreman_rh_cloud.po +19 -0
  33. data/locale/foreman_rh_cloud.pot +19 -0
  34. data/locale/gemspec.rb +2 -0
  35. data/package.json +125 -0
  36. data/test/controllers/accounts_controller_test.rb +25 -0
  37. data/test/controllers/reports_controller_test.rb +21 -0
  38. data/test/controllers/uploads_controller_test.rb +21 -0
  39. data/test/factories/inventory_upload_factories.rb +88 -0
  40. data/test/test_plugin_helper.rb +26 -0
  41. data/test/unit/archived_report_generator_test.rb +61 -0
  42. data/test/unit/metadata_generator_test.rb +40 -0
  43. data/test/unit/shell_process_job_test.rb +27 -0
  44. data/test/unit/slice_generator_test.rb +177 -0
  45. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +37 -0
  46. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +74 -0
  47. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.stories.js +18 -0
  48. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +65 -0
  49. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListConstants.js +9 -0
  50. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +0 -0
  51. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +55 -0
  52. data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +8 -0
  53. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.fixtures.js +0 -0
  54. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.js +16 -0
  55. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyStateHelper.js +0 -0
  56. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/EmptyState.test.js +13 -0
  57. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +26 -0
  58. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/emptyState.scss +7 -0
  59. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/index.js +1 -0
  60. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.fixtures.js +0 -0
  61. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorState.js +23 -0
  62. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/ErrorStateHelper.js +0 -0
  63. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/ErrorState.test.js +13 -0
  64. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/__tests__/__snapshots__/ErrorState.test.js.snap +20 -0
  65. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/errorState.scss +18 -0
  66. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ErrorState/index.js +1 -0
  67. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +1 -0
  68. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +41 -0
  69. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItemHelper.js +0 -0
  70. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/ListItem.test.js +13 -0
  71. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +50 -0
  72. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/index.js +1 -0
  73. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/listItem.scss +0 -0
  74. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.fixtures.js +7 -0
  75. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +43 -0
  76. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatusHelper.js +29 -0
  77. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/ListItemStatus.test.js +14 -0
  78. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/__tests__/__snapshots__/ListItemStatus.test.js.snap +78 -0
  79. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/index.js +1 -0
  80. data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/listItemStatus.scss +16 -0
  81. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountList.test.js +13 -0
  82. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListActions.test.js +20 -0
  83. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListIntegration.test.js +14 -0
  84. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +60 -0
  85. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +26 -0
  86. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +44 -0
  87. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +47 -0
  88. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +69 -0
  89. data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +46 -0
  90. data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +9 -0
  91. data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +27 -0
  92. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.fixtures.js +50 -0
  93. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +145 -0
  94. data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.stories.js +19 -0
  95. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +87 -0
  96. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardConstants.js +9 -0
  97. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardHelper.js +0 -0
  98. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardReducer.js +68 -0
  99. data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardSelectors.js +17 -0
  100. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/Dashboard.test.js +25 -0
  101. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +39 -0
  102. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardIntegration.test.js +16 -0
  103. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardReducer.test.js +64 -0
  104. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardSelectors.test.js +45 -0
  105. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/Dashboard.test.js.snap +35 -0
  106. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardActions.test.js.snap +76 -0
  107. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardReducer.test.js.snap +44 -0
  108. data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/DashboardSelectors.test.js.snap +42 -0
  109. data/webpack/ForemanInventoryUpload/Components/Dashboard/dashboard.scss +0 -0
  110. data/webpack/ForemanInventoryUpload/Components/Dashboard/index.js +34 -0
  111. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.fixtures.js +0 -0
  112. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +22 -0
  113. data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownloadHelper.js +0 -0
  114. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/FileDownload.test.js +13 -0
  115. data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +25 -0
  116. data/webpack/ForemanInventoryUpload/Components/FileDownload/fileDownload.scss +3 -0
  117. data/webpack/ForemanInventoryUpload/Components/FileDownload/index.js +1 -0
  118. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.fixtures.js +0 -0
  119. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModal.js +50 -0
  120. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/FullScreenModalHelper.js +0 -0
  121. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/FullScreenModal.test.js +13 -0
  122. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/__tests__/__snapshots__/FullScreenModal.test.js.snap +64 -0
  123. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/fullScreenModal.scss +18 -0
  124. data/webpack/ForemanInventoryUpload/Components/FullScreenModal/index.js +1 -0
  125. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +10 -0
  126. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.js +83 -0
  127. data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainerHelper.js +0 -0
  128. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +26 -0
  129. data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +89 -0
  130. data/webpack/ForemanInventoryUpload/Components/NavContainer/index.js +1 -0
  131. data/webpack/ForemanInventoryUpload/Components/NavContainer/navContainer.scss +7 -0
  132. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +16 -0
  133. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +57 -0
  134. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerateHelper.js +0 -0
  135. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/ReportGenerate.test.js +14 -0
  136. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/__snapshots__/ReportGenerate.test.js.snap +45 -0
  137. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/index.js +1 -0
  138. data/webpack/ForemanInventoryUpload/Components/ReportGenerate/reportGenerate.scss +0 -0
  139. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.fixtures.js +18 -0
  140. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +53 -0
  141. data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUploadHelper.js +0 -0
  142. data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/ReportUpload.test.js +14 -0
  143. data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/__snapshots__/ReportUpload.test.js.snap +45 -0
  144. data/webpack/ForemanInventoryUpload/Components/ReportUpload/index.js +1 -0
  145. data/webpack/ForemanInventoryUpload/Components/ReportUpload/reportUpload.scss +0 -0
  146. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.fixtures.js +3 -0
  147. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRun.js +27 -0
  148. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/ScheduledRunHelper.js +0 -0
  149. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/ScheduledRun.test.js +14 -0
  150. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/__tests__/__snapshots__/ScheduledRun.test.js.snap +25 -0
  151. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/index.js +1 -0
  152. data/webpack/ForemanInventoryUpload/Components/ScheduledRun/scheduledRun.scss +11 -0
  153. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.fixtures.js +0 -0
  154. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +56 -0
  155. data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChartHelper.js +0 -0
  156. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/StatusChart.test.js +13 -0
  157. data/webpack/ForemanInventoryUpload/Components/StatusChart/__tests__/__snapshots__/StatusChart.test.js.snap +74 -0
  158. data/webpack/ForemanInventoryUpload/Components/StatusChart/index.js +1 -0
  159. data/webpack/ForemanInventoryUpload/Components/StatusChart/statusChart.scss +8 -0
  160. data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.fixtures.js +0 -0
  161. data/webpack/ForemanInventoryUpload/Components/TabBody/TabBody.js +31 -0
  162. data/webpack/ForemanInventoryUpload/Components/TabBody/TabBodyHelper.js +0 -0
  163. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/TabBody.test.js +13 -0
  164. data/webpack/ForemanInventoryUpload/Components/TabBody/__tests__/__snapshots__/TabBody.test.js.snap +19 -0
  165. data/webpack/ForemanInventoryUpload/Components/TabBody/index.js +1 -0
  166. data/webpack/ForemanInventoryUpload/Components/TabBody/tabBody.scss +3 -0
  167. data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.fixtures.js +0 -0
  168. data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainer.js +24 -0
  169. data/webpack/ForemanInventoryUpload/Components/TabContainer/TabContainerHelper.js +0 -0
  170. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/TabContainer.test.js +13 -0
  171. data/webpack/ForemanInventoryUpload/Components/TabContainer/__tests__/__snapshots__/TabContainer.test.js.snap +18 -0
  172. data/webpack/ForemanInventoryUpload/Components/TabContainer/index.js +1 -0
  173. data/webpack/ForemanInventoryUpload/Components/TabContainer/tabContainer.scss +8 -0
  174. data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.fixtures.js +0 -0
  175. data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooter.js +19 -0
  176. data/webpack/ForemanInventoryUpload/Components/TabFooter/TabFooterHelper.js +0 -0
  177. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/TabFooter.test.js +13 -0
  178. data/webpack/ForemanInventoryUpload/Components/TabFooter/__tests__/__snapshots__/TabFooter.test.js.snap +12 -0
  179. data/webpack/ForemanInventoryUpload/Components/TabFooter/index.js +1 -0
  180. data/webpack/ForemanInventoryUpload/Components/TabFooter/tabFooter.scss +0 -0
  181. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.fixtures.js +0 -0
  182. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +47 -0
  183. data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeaderHelper.js +0 -0
  184. data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +13 -0
  185. data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/__snapshots__/TabHeader.test.js.snap +43 -0
  186. data/webpack/ForemanInventoryUpload/Components/TabHeader/index.js +1 -0
  187. data/webpack/ForemanInventoryUpload/Components/TabHeader/tabHeader.scss +21 -0
  188. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.fixtures.js +10 -0
  189. data/webpack/ForemanInventoryUpload/Components/Terminal/Terminal.js +112 -0
  190. data/webpack/ForemanInventoryUpload/Components/Terminal/TerminalHelper.js +6 -0
  191. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/Terminal.test.js +35 -0
  192. data/webpack/ForemanInventoryUpload/Components/Terminal/__tests__/__snapshots__/Terminal.test.js.snap +98 -0
  193. data/webpack/ForemanInventoryUpload/Components/Terminal/index.js +1 -0
  194. data/webpack/ForemanInventoryUpload/Components/Terminal/terminal.scss +31 -0
  195. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.js +15 -0
  196. data/webpack/ForemanInventoryUpload/ForemanInventoryUpload.test.js +10 -0
  197. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadReducers.js +12 -0
  198. data/webpack/ForemanInventoryUpload/ForemanInventoryUploadSelectors.js +4 -0
  199. data/webpack/ForemanInventoryUpload/__snapshots__/ForemanInventoryUpload.test.js.snap +16 -0
  200. data/webpack/ForemanInventoryUpload/index.js +1 -0
  201. data/webpack/__mocks__/foremanReact/API.js +7 -0
  202. data/webpack/__mocks__/foremanReact/common/I18n.js +5 -0
  203. data/webpack/__mocks__/foremanReact/common/helpers.js +3 -0
  204. data/webpack/index.js +18 -0
  205. data/webpack/stories/ForemanInventoryUploadReducers.js +3 -0
  206. data/webpack/stories/configureStore.js +15 -0
  207. data/webpack/stories/decorators/index.js +1 -0
  208. data/webpack/stories/decorators/withCardsDecorator.js +14 -0
  209. data/webpack/stories/index.js +10 -0
  210. data/webpack/stories/index.scss +7 -0
  211. data/webpack/test_setup.js +6 -0
  212. metadata +318 -0
@@ -0,0 +1,44 @@
1
+ #! /bin/sh
2
+
3
+ DEST=<%= @upload_url %>
4
+
5
+ if [ -z "$FILES" ]
6
+ then
7
+ FILES=./*.tar.gz
8
+ fi
9
+
10
+ if [ -n "$CER_PATH" ]
11
+ then
12
+ AUTH_KEY="--cert"
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\""
27
+ fi
28
+
29
+ # /tmp/a b/x.pem
30
+ # curl --cert /tmp/a\ b/x.pem
31
+
32
+ SCRIPT_DIR=$(realpath "$(dirname "${BASH_SOURCE:-0}")")
33
+ DONE_DIR="$SCRIPT_DIR/done/"
34
+ mkdir -p $DONE_DIR
35
+
36
+ for f in $FILES
37
+ do
38
+ curl -k -vvv -# --fail -F "file=@$f;type=application/vnd.redhat.qpc.tar+tgz" $DEST "$AUTH_KEY" "$AUTH_VAL"
39
+ if [ $? -eq 0 ]; then
40
+ mv $f $DONE_DIR
41
+ echo "Done: $f"
42
+ fi
43
+ done
44
+ echo "Uploaded files moved to done/ folder"
@@ -0,0 +1,4 @@
1
+ require 'foreman_rh_cloud/engine.rb'
2
+
3
+ module ForemanRhCloud
4
+ end
@@ -0,0 +1,62 @@
1
+ require 'katello'
2
+ require 'redhat_access'
3
+
4
+ module ForemanRhCloud
5
+ class Engine < ::Rails::Engine
6
+ engine_name 'foreman_rh_cloud'
7
+
8
+ config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
9
+ config.autoload_paths += Dir["#{config.root}/app/helpers/concerns"]
10
+ config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
11
+ config.autoload_paths += Dir["#{config.root}/app/overrides"]
12
+ config.autoload_paths += Dir["#{config.root}/lib"]
13
+
14
+ config.eager_load_paths += Dir["#{config.root}/lib"]
15
+
16
+ # Add any db migrations
17
+ initializer 'foreman_rh_cloud.load_app_instance_data' do |app|
18
+ ForemanRhCloud::Engine.paths['db/migrate'].existent.each do |path|
19
+ app.config.paths['db/migrate'] << path
20
+ end
21
+ end
22
+
23
+ initializer 'foreman_rh_cloud.register_plugin', :before => :finisher_hook do |_app|
24
+ Foreman::Plugin.register :foreman_rh_cloud do
25
+ requires_foreman '>= 1.20'
26
+
27
+ # Add permissions
28
+ security_block :foreman_rh_cloud do
29
+ permission :view_foreman_rh_cloud, :'foreman_rh_cloud/reports' => [:last]
30
+ end
31
+
32
+ # Add a new role called 'Discovery' if it doesn't exist
33
+ role 'ForemanRhCloud', [:view_foreman_rh_cloud]
34
+
35
+ # Adding a sub menu after hosts menu
36
+ sub_menu :top_menu, :foreman_rh_cloud, :caption => N_('RH Cloud'), :icon => 'fa fa-cloud-upload' do
37
+ menu :top_menu, :level1, :caption => N_('Inventory Upload'), :url_hash => { controller: :'foreman_inventory_upload/react', :action => :index}
38
+ end
39
+ end
40
+ end
41
+
42
+ initializer "foreman_rh_cloud.set_dynflow.config.on_init", :before => :finisher_hook do |_app|
43
+ unless Rails.env.test?
44
+ ForemanTasks.dynflow.config.on_init do |world|
45
+ ForemanInventoryUpload::Async::GenerateAllReportsJob.spawn_if_missing(world)
46
+ end
47
+ end
48
+ end
49
+
50
+ rake_tasks do
51
+ Rake::Task['db:seed'].enhance do
52
+ ForemanRhCloud::Engine.load_seed
53
+ end
54
+ end
55
+
56
+ initializer 'foreman_rh_cloud.register_gettext', after: :load_config_initializers do |_app|
57
+ locale_dir = File.join(File.expand_path('../..', __dir__), 'locale')
58
+ locale_domain = 'foreman_rh_cloud'
59
+ Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,3 @@
1
+ module ForemanRhCloud
2
+ VERSION = '0.9.4'.freeze
3
+ end
@@ -0,0 +1,37 @@
1
+ require 'rake/testtask'
2
+
3
+ # Tests
4
+ namespace :test do
5
+ desc 'Test ForemanRhCloud'
6
+ Rake::TestTask.new(:foreman_rh_cloud) do |t|
7
+ test_dir = File.join(File.dirname(__FILE__), '../..', 'test')
8
+ t.libs << ['test', test_dir]
9
+ t.pattern = "#{test_dir}/**/*_test.rb"
10
+ t.verbose = true
11
+ t.warning = false
12
+ end
13
+ end
14
+
15
+ namespace :foreman_rh_cloud do
16
+ task :rubocop => :environment do
17
+ begin
18
+ require 'rubocop/rake_task'
19
+ RuboCop::RakeTask.new(:rubocop_foreman_rh_cloud) do |task|
20
+ task.patterns = ["#{ForemanRhCloud::Engine.root}/app/**/*.rb",
21
+ "#{ForemanRhCloud::Engine.root}/lib/**/*.rb",
22
+ "#{ForemanRhCloud::Engine.root}/test/**/*.rb"]
23
+ end
24
+ rescue
25
+ puts 'Rubocop not loaded.'
26
+ end
27
+
28
+ Rake::Task['rubocop_foreman_rh_cloud'].invoke
29
+ end
30
+ end
31
+
32
+ Rake::Task[:test].enhance ['test:foreman_rh_cloud']
33
+
34
+ load 'tasks/jenkins.rake'
35
+ if Rake::Task.task_defined?(:'jenkins:unit')
36
+ Rake::Task['jenkins:unit'].enhance ['test:foreman_rh_cloud', 'foreman_rh_cloud:rubocop']
37
+ end
@@ -0,0 +1,29 @@
1
+ require 'tempfile'
2
+
3
+ namespace :foreman_inventory_upload do
4
+ namespace :report do
5
+ desc 'Generate inventory report to be sent to Red Hat cloud'
6
+ task generate: :environment do
7
+ portal_user = ENV['portal_user']
8
+ organizations = [ENV['organization_id']]
9
+ base_folder = ENV['target'] || Dir.pwd
10
+
11
+ unless portal_user || organizations.empty?
12
+ puts "Must specify either portal_user or organization_id"
13
+ end
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
27
+ end
28
+ end
29
+ end
data/locale/Makefile ADDED
@@ -0,0 +1,60 @@
1
+ #
2
+ # Makefile for PO merging and MO generation. More info in the README.
3
+ #
4
+ # make all-mo (default) - generate MO files
5
+ # make check - check translations using translate-tool
6
+ # make tx-update - download and merge translations from Transifex
7
+ # make clean - clean everything
8
+ #
9
+ DOMAIN = foreman_rh_cloud
10
+ VERSION = $(shell ruby -e 'require "rubygems";spec = Gem::Specification::load(Dir.glob("../*.gemspec")[0]);puts spec.version')
11
+ POTFILE = $(DOMAIN).pot
12
+ MOFILE = $(DOMAIN).mo
13
+ POFILES = $(shell find . -name '$(DOMAIN).po')
14
+ MOFILES = $(patsubst %.po,%.mo,$(POFILES))
15
+ POXFILES = $(patsubst %.po,%.pox,$(POFILES))
16
+ EDITFILES = $(patsubst %.po,%.edit.po,$(POFILES))
17
+
18
+ %.mo: %.po
19
+ mkdir -p $(shell dirname $@)/LC_MESSAGES
20
+ msgfmt -o $(shell dirname $@)/LC_MESSAGES/$(MOFILE) $<
21
+
22
+ # Generate MO files from PO files
23
+ all-mo: $(MOFILES)
24
+
25
+ # Check for malformed strings
26
+ %.pox: %.po
27
+ msgfmt -c $<
28
+ pofilter --nofuzzy -t variables -t blank -t urls -t emails -t long -t newlines \
29
+ -t endwhitespace -t endpunc -t puncspacing -t options -t printf -t validchars --gnome $< > $@
30
+ cat $@
31
+ ! grep -q msgid $@
32
+
33
+ %.edit.po:
34
+ touch $@
35
+
36
+ check: $(POXFILES)
37
+
38
+ # Unify duplicate translations
39
+ uniq-po:
40
+ for f in $(shell find ./ -name "*.po") ; do \
41
+ msguniq $$f -o $$f ; \
42
+ done
43
+
44
+ tx-pull: $(EDITFILES)
45
+ tx pull -f
46
+ for f in $(EDITFILES) ; do \
47
+ sed -i 's/^\("Project-Id-Version: \).*$$/\1$(DOMAIN) $(VERSION)\\n"/' $$f; \
48
+ done
49
+
50
+ tx-update: tx-pull
51
+ @echo
52
+ @echo Run rake plugin:gettext[$(DOMAIN)] from the Foreman installation, then make -C locale mo-files to finish
53
+ @echo
54
+
55
+ mo-files: $(MOFILES)
56
+ git add $(POFILES) $(POTFILE) ../locale/*/LC_MESSAGES
57
+ git commit -m "i18n - pulling from tx"
58
+ @echo
59
+ @echo Changes commited!
60
+ @echo
@@ -0,0 +1,19 @@
1
+ # foreman_rh_cloud
2
+ #
3
+ # This file is distributed under the same license as foreman_rh_cloud.
4
+ #
5
+ #, fuzzy
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: version 0.0.1\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2014-08-20 08:46+0100\n"
11
+ "PO-Revision-Date: 2014-08-20 08:54+0100\n"
12
+ "Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
13
+ "Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
14
+ "Language: \n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
+
@@ -0,0 +1,19 @@
1
+ # foreman_rh_cloud
2
+ #
3
+ # This file is distributed under the same license as foreman_rh_cloud.
4
+ #
5
+ #, fuzzy
6
+ msgid ""
7
+ msgstr ""
8
+ "Project-Id-Version: version 0.0.1\n"
9
+ "Report-Msgid-Bugs-To: \n"
10
+ "POT-Creation-Date: 2014-08-20 08:46+0100\n"
11
+ "PO-Revision-Date: 2014-08-20 08:46+0100\n"
12
+ "Last-Translator: Foreman Team <foreman-dev@googlegroups.com>\n"
13
+ "Language-Team: Foreman Team <foreman-dev@googlegroups.com>\n"
14
+ "Language: \n"
15
+ "MIME-Version: 1.0\n"
16
+ "Content-Type: text/plain; charset=UTF-8\n"
17
+ "Content-Transfer-Encoding: 8bit\n"
18
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
19
+
data/locale/gemspec.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Matches foreman_rh_cloud.gemspec
2
+ _('TODO: Description of ForemanRhCloud.')
data/package.json ADDED
@@ -0,0 +1,125 @@
1
+ {
2
+ "name": "foreman_rh_cloud",
3
+ "version": "0.0.1",
4
+ "description": "Inventory Upload =============",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "lint": "./node_modules/.bin/eslint -c .eslintrc webpack/",
8
+ "test": "node node_modules/.bin/jest --no-cache",
9
+ "test:watch": "node node_modules/.bin/jest --watchAll",
10
+ "test:current": "node node_modules/.bin/jest --watch",
11
+ "coveralls": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
12
+ "storybook": "start-storybook -p 6006",
13
+ "storybook:build": "node --max_old_space_size=2048 ./node_modules/.bin/build-storybook --config-dir .storybook --output-dir .storybook-dist",
14
+ "storybook:deploy": "surge --project .storybook-dist"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/theforeman/foreman_rh_cloud.git"
19
+ },
20
+ "bugs": {
21
+ "url": "http://projects.theforeman.org/projects/foreman_rh_cloud/issues"
22
+ },
23
+ "optionalDependencies": {
24
+ "babel-plugin-module-resolver": "^3.2.0"
25
+ },
26
+ "devDependencies": {
27
+ "@storybook/addon-actions": "^5.0.1",
28
+ "@storybook/addon-knobs": "^5.0.1",
29
+ "@storybook/react": "^5.0.1",
30
+ "babel-cli": "^6.10.1",
31
+ "babel-core": "^6.26.3",
32
+ "babel-eslint": "^8.2.3",
33
+ "babel-jest": "^23.6.0",
34
+ "babel-loader": "^7.1.1",
35
+ "babel-plugin-dynamic-import-node": "^2.0.0",
36
+ "babel-plugin-lodash": "^3.3.4",
37
+ "babel-plugin-syntax-dynamic-import": "^6.18.0",
38
+ "babel-plugin-transform-class-properties": "^6.24.1",
39
+ "babel-plugin-transform-object-assign": "^6.8.0",
40
+ "babel-plugin-transform-object-rest-spread": "^6.8.0",
41
+ "babel-preset-env": "^1.7.0",
42
+ "babel-preset-react": "^6.5.0",
43
+ "coveralls": "^3.0.0",
44
+ "enzyme": "^3.4.0",
45
+ "enzyme-adapter-react-16": "^1.4.0",
46
+ "enzyme-to-json": "^3.2.1",
47
+ "eslint": "^4.10.0",
48
+ "eslint-import-resolver-babel-module": "^4.0.0",
49
+ "eslint-plugin-patternfly-react": "0.2.0",
50
+ "identity-obj-proxy": "^3.0.0",
51
+ "jed": "^1.1.1",
52
+ "jest-cli": "^23.6.0",
53
+ "jest-prop-type-error": "^1.1.0",
54
+ "node-sass": "^4.5.0",
55
+ "patternfly": "^3.58.0",
56
+ "prettier": "^1.13.5",
57
+ "raf": "^3.4.0",
58
+ "react-redux-test-utils": "^0.1.1",
59
+ "react-remarkable": "^1.1.3",
60
+ "sass-loader": "^6.0.7",
61
+ "stylelint": "^9.3.0",
62
+ "stylelint-config-standard": "^18.0.0",
63
+ "surge": "^0.20.3"
64
+ },
65
+ "dependencies": {
66
+ "babel-polyfill": "^6.26.0",
67
+ "classnames": "^2.2.5",
68
+ "lodash": "^4.17.10",
69
+ "patternfly-react": "^2.19.1",
70
+ "prop-types": "^15.6.0",
71
+ "react": "^16.4.0",
72
+ "react-dom": "^16.4.0",
73
+ "react-intl": "^2.8.0",
74
+ "react-redux": "^5.0.6",
75
+ "redux": "^3.6.0",
76
+ "redux-thunk": "^2.2.0",
77
+ "reselect": "^3.0.1",
78
+ "seamless-immutable": "^7.1.2",
79
+ "urijs": "^1.18.10",
80
+ "uuid": "^3.0.1"
81
+ },
82
+ "jest": {
83
+ "automock": true,
84
+ "verbose": true,
85
+ "testMatch": [
86
+ "**/*.test.js"
87
+ ],
88
+ "testURL": "http://localhost/",
89
+ "collectCoverage": true,
90
+ "collectCoverageFrom": [
91
+ "webpack/**/*.js",
92
+ "!webpack/index.js",
93
+ "!webpack/test_setup.js",
94
+ "!webpack/**/bundle*",
95
+ "!webpack/stories/**",
96
+ "!webpack/**/*stories.js"
97
+ ],
98
+ "coverageReporters": [
99
+ "lcov"
100
+ ],
101
+ "unmockedModulePathPatterns": [
102
+ "webpack/",
103
+ "react",
104
+ "node_modules/"
105
+ ],
106
+ "moduleNameMapper": {
107
+ "^.+\\.(png|gif|css|scss)$": "identity-obj-proxy"
108
+ },
109
+ "globals": {
110
+ "__testing__": true
111
+ },
112
+ "transform": {
113
+ "^.+\\.js$": "babel-jest"
114
+ },
115
+ "moduleDirectories": [
116
+ "node_modules",
117
+ "webpack"
118
+ ],
119
+ "setupFiles": [
120
+ "raf/polyfill",
121
+ "jest-prop-type-error",
122
+ "./webpack/test_setup.js"
123
+ ]
124
+ }
125
+ }
@@ -0,0 +1,25 @@
1
+ require 'test_plugin_helper'
2
+
3
+ class AccountsControllerTest < ActionController::TestCase
4
+ tests ForemanInventoryUpload::AccountsController
5
+
6
+ include FolderIsolation
7
+
8
+ test 'Returns statuses for each process type' do
9
+ test_org = FactoryBot.create(:organization)
10
+
11
+ generate_label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(test_org.id)
12
+ generate_output = ForemanInventoryUpload::Async::ProgressOutput.register(generate_label)
13
+ generate_output.status = 'generate_status_test'
14
+ upload_label = ForemanInventoryUpload::Async::UploadReportJob.output_label(test_org.id)
15
+ upload_output = ForemanInventoryUpload::Async::ProgressOutput.register(upload_label)
16
+ upload_output.status = 'upload_status_test'
17
+
18
+ get :index, session: set_session_user
19
+
20
+ assert_response :success
21
+ actual = JSON.parse(response.body)['accounts'][test_org.id.to_s]
22
+ assert_equal 'generate_status_test', actual['generate_report_status']
23
+ assert_equal 'upload_status_test', actual['upload_report_status']
24
+ end
25
+ end