foreman_patch 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +619 -0
- data/README.md +38 -0
- data/Rakefile +53 -0
- data/app/assets/javascript/foreman_patch/plan_edit_windows.js +9 -0
- data/app/assets/stylesheets/foreman_patch/cycle_plans.scss +6 -0
- data/app/assets/stylesheets/foreman_patch/foreman_patch.css +4 -0
- data/app/controllers/concerns/foreman_patch/parameters/ticket_field.rb +26 -0
- data/app/controllers/foreman_patch/api/v2/base_controller.rb +12 -0
- data/app/controllers/foreman_patch/api/v2/cycles_controller.rb +78 -0
- data/app/controllers/foreman_patch/api/v2/groups_controller.rb +70 -0
- data/app/controllers/foreman_patch/api/v2/host_groups_controller.rb +13 -0
- data/app/controllers/foreman_patch/api/v2/invocations_controller.rb +70 -0
- data/app/controllers/foreman_patch/api/v2/plans_controller.rb +79 -0
- data/app/controllers/foreman_patch/api/v2/rounds_controller.rb +77 -0
- data/app/controllers/foreman_patch/api/v2/window_plans_controller.rb +73 -0
- data/app/controllers/foreman_patch/api/v2/windows_controller.rb +85 -0
- data/app/controllers/foreman_patch/concerns/api/v2/hosts_controller_extensions.rb +21 -0
- data/app/controllers/foreman_patch/concerns/hosts_controller_extensions.rb +61 -0
- data/app/controllers/foreman_patch/cycles_controller.rb +34 -0
- data/app/controllers/foreman_patch/groups_controller.rb +68 -0
- data/app/controllers/foreman_patch/invocations_controller.rb +51 -0
- data/app/controllers/foreman_patch/plans_controller.rb +59 -0
- data/app/controllers/foreman_patch/rounds_controller.rb +18 -0
- data/app/controllers/foreman_patch/ticket_fields_controller.rb +37 -0
- data/app/controllers/foreman_patch/window_plans_controller.rb +60 -0
- data/app/controllers/foreman_patch/windows_controller.rb +58 -0
- data/app/helpers/concerns/foreman_patch/hosts_helper_extensions.rb +13 -0
- data/app/helpers/foreman_patch/cycles_helper.rb +19 -0
- data/app/helpers/foreman_patch/hosts_helper.rb +52 -0
- data/app/helpers/foreman_patch/patching_helper.rb +116 -0
- data/app/helpers/foreman_patch/plans_helper.rb +45 -0
- data/app/helpers/foreman_patch/ticket_helper.rb +11 -0
- data/app/helpers/foreman_patch/window_patching_helper.rb +20 -0
- data/app/helpers/foreman_patch/window_plans_helper.rb +13 -0
- data/app/helpers/foreman_patch/windows_helper.rb +17 -0
- data/app/lib/actions/foreman_patch/cycle/complete.rb +41 -0
- data/app/lib/actions/foreman_patch/cycle/create.rb +69 -0
- data/app/lib/actions/foreman_patch/cycle/initiate.rb +68 -0
- data/app/lib/actions/foreman_patch/cycle/plan.rb +73 -0
- data/app/lib/actions/foreman_patch/cycle/prepare_content.rb +123 -0
- data/app/lib/actions/foreman_patch/host/reschedule.rb +32 -0
- data/app/lib/actions/foreman_patch/invocation/action.rb +135 -0
- data/app/lib/actions/foreman_patch/invocation/ensure_services.rb +47 -0
- data/app/lib/actions/foreman_patch/invocation/patch.rb +93 -0
- data/app/lib/actions/foreman_patch/invocation/reschedule.rb +21 -0
- data/app/lib/actions/foreman_patch/invocation/restart.rb +101 -0
- data/app/lib/actions/foreman_patch/invocation/update_packages.rb +52 -0
- data/app/lib/actions/foreman_patch/invocation/wait_for_host.rb +103 -0
- data/app/lib/actions/foreman_patch/round/add_missing_hosts.rb +21 -0
- data/app/lib/actions/foreman_patch/round/create.rb +37 -0
- data/app/lib/actions/foreman_patch/round/patch.rb +81 -0
- data/app/lib/actions/foreman_patch/round/plan.rb +33 -0
- data/app/lib/actions/foreman_patch/round/resolve_hosts.rb +45 -0
- data/app/lib/actions/foreman_patch/window/create.rb +41 -0
- data/app/lib/actions/foreman_patch/window/patch.rb +72 -0
- data/app/lib/actions/foreman_patch/window/plan.rb +43 -0
- data/app/lib/actions/foreman_patch/window/publish.rb +32 -0
- data/app/lib/actions/foreman_patch/window/resolve_hosts.rb +31 -0
- data/app/lib/actions/helpers/failure_notification.rb +20 -0
- data/app/lib/actions/helpers/with_feature_action.rb +102 -0
- data/app/lib/actions/middleware/check_exit_status.rb +31 -0
- data/app/mailers/foreman_patch/cycle_mailer.rb +17 -0
- data/app/mailers/foreman_patch/group_mailer.rb +41 -0
- data/app/mailers/foreman_patch/invocation_mailer.rb +19 -0
- data/app/models/foreman_patch/concerns/group_facet_host_extensions.rb +35 -0
- data/app/models/foreman_patch/concerns/host_managed_extensions.rb +17 -0
- data/app/models/foreman_patch/cycle.rb +49 -0
- data/app/models/foreman_patch/group.rb +43 -0
- data/app/models/foreman_patch/host/group_facet.rb +13 -0
- data/app/models/foreman_patch/invocation.rb +60 -0
- data/app/models/foreman_patch/plan.rb +110 -0
- data/app/models/foreman_patch/plan_task_group.rb +11 -0
- data/app/models/foreman_patch/round.rb +68 -0
- data/app/models/foreman_patch/ticket_field.rb +23 -0
- data/app/models/foreman_patch/window.rb +123 -0
- data/app/models/foreman_patch/window_plan.rb +77 -0
- data/app/models/foreman_patch/window_task_group.rb +11 -0
- data/app/models/setting/patching.rb +57 -0
- data/app/services/foreman_patch/cycle_name_generator.rb +38 -0
- data/app/services/foreman_patch/ticket/affected_items.rb +110 -0
- data/app/services/foreman_patch/ticket/api.rb +68 -0
- data/app/services/foreman_patch/ticket/change_request.rb +92 -0
- data/app/services/foreman_patch/ticket/field_render.rb +21 -0
- data/app/services/foreman_patch/ticket/payload.rb +136 -0
- data/app/services/foreman_patch/ticket.rb +14 -0
- data/app/views/dashboard/_foreman_patch_widget.html.erb +2 -0
- data/app/views/foreman_patch/api/v2/cycles/base.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/cycles/create.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/cycles/index.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/cycles/show.json.rabl +9 -0
- data/app/views/foreman_patch/api/v2/cycles/update.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/group_facet/base.json.rabl +7 -0
- data/app/views/foreman_patch/api/v2/group_facet/base_with_root.json.rabl +4 -0
- data/app/views/foreman_patch/api/v2/group_facet/show.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/groups/base.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/groups/create.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/groups/index.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/groups/show.json.rabl +14 -0
- data/app/views/foreman_patch/api/v2/groups/update.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/invocations/base.json.rabl +6 -0
- data/app/views/foreman_patch/api/v2/invocations/index.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/invocations/phase.json.rabl +7 -0
- data/app/views/foreman_patch/api/v2/invocations/show.json.rabl +7 -0
- data/app/views/foreman_patch/api/v2/plans/base.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/plans/create.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/plans/index.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/plans/show.json.rabl +9 -0
- data/app/views/foreman_patch/api/v2/plans/update.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/rounds/base.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/rounds/index.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/rounds/show.json.rabl +17 -0
- data/app/views/foreman_patch/api/v2/rounds/status.json.rabl +11 -0
- data/app/views/foreman_patch/api/v2/window_plans/base.json.rabl +4 -0
- data/app/views/foreman_patch/api/v2/window_plans/create.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/window_plans/index.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/window_plans/show.json.rabl +14 -0
- data/app/views/foreman_patch/api/v2/window_plans/update.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/windows/base.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/windows/index.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/windows/schedule.json.rabl +13 -0
- data/app/views/foreman_patch/api/v2/windows/show.json.rabl +13 -0
- data/app/views/foreman_patch/api/v2/windows/update.json.rabl +3 -0
- data/app/views/foreman_patch/cycle_mailer/_details.html.erb +4 -0
- data/app/views/foreman_patch/cycle_mailer/_round.html.erb +12 -0
- data/app/views/foreman_patch/cycle_mailer/_summary.html.erb +6 -0
- data/app/views/foreman_patch/cycle_mailer/_window.html.erb +4 -0
- data/app/views/foreman_patch/cycle_mailer/planned.html.erb +7 -0
- data/app/views/foreman_patch/cycles/_form.html.erb +9 -0
- data/app/views/foreman_patch/cycles/edit.html.erb +41 -0
- data/app/views/foreman_patch/cycles/index.html.erb +45 -0
- data/app/views/foreman_patch/cycles/show.html.erb +26 -0
- data/app/views/foreman_patch/group_mailer/_dashboard.html.erb +31 -0
- data/app/views/foreman_patch/group_mailer/_list.html.erb +17 -0
- data/app/views/foreman_patch/group_mailer/completed.html.erb +16 -0
- data/app/views/foreman_patch/group_mailer/initiated.html.erb +4 -0
- data/app/views/foreman_patch/groups/_form.html.erb +9 -0
- data/app/views/foreman_patch/groups/edit.html.erb +3 -0
- data/app/views/foreman_patch/groups/index.html.erb +40 -0
- data/app/views/foreman_patch/groups/new.html.erb +3 -0
- data/app/views/foreman_patch/hosts/hosts/new_action.html.erb +1 -0
- data/app/views/foreman_patch/hosts/new_action.html.erb +1 -0
- data/app/views/foreman_patch/invocation_mailer/_output_line_set.html.erb +6 -0
- data/app/views/foreman_patch/invocation_mailer/_output_line_set.text.erb +3 -0
- data/app/views/foreman_patch/invocation_mailer/failure.html.erb +50 -0
- data/app/views/foreman_patch/invocation_mailer/failure.text.erb +10 -0
- data/app/views/foreman_patch/invocations/_output_line_set.html.erb +8 -0
- data/app/views/foreman_patch/invocations/_phase.html.erb +17 -0
- data/app/views/foreman_patch/invocations/_primary.html.erb +1 -0
- data/app/views/foreman_patch/invocations/_refresh.js.erb +7 -0
- data/app/views/foreman_patch/invocations/show.html.erb +44 -0
- data/app/views/foreman_patch/invocations/show.js.erb +17 -0
- data/app/views/foreman_patch/layouts/react.html.erb +17 -0
- data/app/views/foreman_patch/plans/_form.html.erb +12 -0
- data/app/views/foreman_patch/plans/edit.html.erb +6 -0
- data/app/views/foreman_patch/plans/index.html.erb +32 -0
- data/app/views/foreman_patch/plans/new.html.erb +3 -0
- data/app/views/foreman_patch/plans/show.html.erb +19 -0
- data/app/views/foreman_patch/rounds/show.html.erb +54 -0
- data/app/views/foreman_patch/ticket_fields/_fields.html.erb +66 -0
- data/app/views/foreman_patch/ticket_fields/edit.html.erb +6 -0
- data/app/views/foreman_patch/ticket_fields/index.html.erb +26 -0
- data/app/views/foreman_patch/ticket_fields/new.html.erb +6 -0
- data/app/views/foreman_patch/window_plans/_form.html.erb +11 -0
- data/app/views/foreman_patch/window_plans/_hidden_layout.html.erb +7 -0
- data/app/views/foreman_patch/window_plans/edit.html.erb +3 -0
- data/app/views/foreman_patch/window_plans/new.html.erb +3 -0
- data/app/views/foreman_patch/windows/_form.html.erb +21 -0
- data/app/views/foreman_patch/windows/_groups.html.erb +2 -0
- data/app/views/foreman_patch/windows/_rounds.html.erb +24 -0
- data/app/views/foreman_patch/windows/_schedule.html.erb +16 -0
- data/app/views/foreman_patch/windows/_ticket.html.erb +12 -0
- data/app/views/foreman_patch/windows/edit.html.erb +3 -0
- data/app/views/foreman_patch/windows/new.html.erb +3 -0
- data/app/views/foreman_patch/windows/show.html.erb +27 -0
- data/app/views/foreman_patch/windows/show.json.erb +4 -0
- data/app/views/hosts/select_multiple_patch_group.html.erb +12 -0
- data/app/views/overrides/patch_groups/_host_patch_group_select.html.erb +9 -0
- data/app/views/templates/ensure_services.erb +28 -0
- data/config/api_routes.rb +37 -0
- data/config/initializers/pagelets.rb +6 -0
- data/config/initializers/safemode_jail.rb +4 -0
- data/config/routes/mount_engine.rb +3 -0
- data/config/routes/overrides.rb +10 -0
- data/config/routes.rb +47 -0
- data/db/migrate/20210202161304_create_foreman_patch_plans.rb +32 -0
- data/db/migrate/20210202163323_create_foreman_patch_cycles.rb +38 -0
- data/db/migrate/20210202164301_create_foreman_patch_groups.rb +37 -0
- data/db/migrate/20210226134103_add_name_to_cycles.rb +31 -0
- data/db/migrate/20210226162824_rename_default_window.rb +5 -0
- data/db/migrate/20210302165058_add_task_to_window_groups.rb +7 -0
- data/db/migrate/20210304141111_create_invocation.rb +16 -0
- data/db/migrate/20210519163923_add_cycle_end_date.rb +29 -0
- data/db/migrate/20210525154113_expand_window_groups.rb +27 -0
- data/db/migrate/20210723160142_add_cycle_plan_task_group.rb +7 -0
- data/db/migrate/20210831160044_cycle_plan_start_correction.rb +5 -0
- data/db/migrate/20210907104645_rename_group_priority.rb +5 -0
- data/db/migrate/20210909130118_remove_old_references.rb +14 -0
- data/db/migrate/20210910141428_rename_round.rb +7 -0
- data/db/migrate/20210910163542_rename_plan.rb +8 -0
- data/db/migrate/20211014212415_round_group_reference.rb +9 -0
- data/db/migrate/20220105224803_add_group_label.rb +25 -0
- data/db/migrate/20220114153808_plan_add_name_generator.rb +5 -0
- data/db/migrate/20220117103808_remove_cycle_description.rb +5 -0
- data/db/migrate/20220406110705_add_window_state.rb +37 -0
- data/db/migrate/20220407161120_add_round_status.rb +9 -0
- data/db/migrate/20220902134800_add_invocation_status.rb +28 -0
- data/db/seeds.d/100-assign_features_with_templates.rb +16 -0
- data/db/seeds.d/160-mail_notifications.rb +38 -0
- data/db/seeds.d/75-job_templates.rb +16 -0
- data/lib/foreman_patch/engine.rb +87 -0
- data/lib/foreman_patch/plugin.rb +47 -0
- data/lib/foreman_patch/version.rb +3 -0
- data/lib/foreman_patch.rb +4 -0
- data/lib/tasks/foreman_patch_tasks.rake +47 -0
- data/locale/Makefile +60 -0
- data/locale/en/foreman_patch.po +19 -0
- data/locale/foreman_patch.pot +19 -0
- data/locale/gemspec.rb +2 -0
- data/package.json +35 -0
- data/public/assets/foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss +6 -0
- data/public/assets/foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css +1 -0
- data/public/assets/foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch.json +1 -0
- data/public/assets/foreman_patch/plan_edit_windows-e656ba411642a7f983b51958ab30ac49c056322d19295a603cff4d5e6c71c8ed.js +1 -0
- data/public/assets/foreman_patch/plan_edit_windows-e656ba411642a7f983b51958ab30ac49c056322d19295a603cff4d5e6c71c8ed.js.gz +0 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.css +1 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.css.gz +0 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.js +6 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.js.gz +0 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.js.map +1 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.js.map.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.css +1 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.css.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.js +6 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.js.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.js.map +1 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.js.map.gz +0 -0
- data/public/webpack/foreman_patch/manifest.json +26 -0
- data/public/webpack/foreman_patch/manifest.json.gz +0 -0
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js +2 -0
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.gz +0 -0
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.map +1 -0
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.map.gz +0 -0
- data/test/factories/foreman_patch_factories.rb +5 -0
- data/test/test_plugin_helper.rb +6 -0
- data/test/unit/foreman_patch_test.rb +11 -0
- data/webpack/components/Cycle/Cycle.js +57 -0
- data/webpack/components/Cycle/CycleActions.js +21 -0
- data/webpack/components/Cycle/CycleConstants.js +2 -0
- data/webpack/components/Cycle/CycleHelpers.js +3 -0
- data/webpack/components/Cycle/CycleSelectors.js +10 -0
- data/webpack/components/Cycle/Window.js +32 -0
- data/webpack/components/Cycle/index.js +41 -0
- data/webpack/components/Groups/Group.js +20 -0
- data/webpack/components/Groups/Groups.js +46 -0
- data/webpack/components/Groups/GroupsHelpers.js +11 -0
- data/webpack/components/Groups/Priority.js +51 -0
- data/webpack/components/Invocation/Invocation.js +47 -0
- data/webpack/components/Invocation/InvocationActions.js +8 -0
- data/webpack/components/Invocation/InvocationConsts.js +1 -0
- data/webpack/components/Invocation/InvocationSelectors.js +14 -0
- data/webpack/components/Invocation/index.js +36 -0
- data/webpack/components/Invocations/Invocations.js +55 -0
- data/webpack/components/Invocations/InvocationsConstants.js +1 -0
- data/webpack/components/Invocations/InvocationsHelpers.js +11 -0
- data/webpack/components/Invocations/InvocationsPage.js +66 -0
- data/webpack/components/Invocations/InvocationsPage.scss +3 -0
- data/webpack/components/Invocations/InvocationsSelectors.js +21 -0
- data/webpack/components/Invocations/components/InvocationItem.js +66 -0
- data/webpack/components/Invocations/components/InvocationStatus.js +51 -0
- data/webpack/components/Invocations/index.js +99 -0
- data/webpack/components/Plan/Plan.js +90 -0
- data/webpack/components/Plan/PlanActions.js +12 -0
- data/webpack/components/Plan/PlanConstants.js +1 -0
- data/webpack/components/Plan/PlanSelectors.js +9 -0
- data/webpack/components/Plan/Window.js +33 -0
- data/webpack/components/Plan/index.js +36 -0
- data/webpack/components/PlanWindow/PlanWindow.js +55 -0
- data/webpack/components/PlanWindow/index.js +32 -0
- data/webpack/components/RoundProgress/AggregateStatus.js +58 -0
- data/webpack/components/RoundProgress/RoundProgress.js +48 -0
- data/webpack/components/RoundProgress/RoundProgressActions.js +9 -0
- data/webpack/components/RoundProgress/RoundProgressConstants.js +1 -0
- data/webpack/components/RoundProgress/RoundProgressSelectors.js +24 -0
- data/webpack/components/RoundProgress/index.js +44 -0
- data/webpack/components/Rounds/Rounds.js +57 -0
- data/webpack/components/Rounds/RoundsActions.js +8 -0
- data/webpack/components/Rounds/RoundsConsts.js +1 -0
- data/webpack/components/Rounds/RoundsSelectors.js +14 -0
- data/webpack/components/Rounds/components/RoundItem.js +52 -0
- data/webpack/components/Rounds/components/RoundStatus.js +40 -0
- data/webpack/components/Rounds/index.js +37 -0
- data/webpack/components/common/Calendar/Calendar.js +86 -0
- data/webpack/components/common/Calendar/Calendar.scss +76 -0
- data/webpack/components/common/Calendar/CalendarConstants.js +1 -0
- data/webpack/components/common/Calendar/CalendarHelpers.js +77 -0
- data/webpack/components/common/Calendar/Day/index.js +9 -0
- data/webpack/components/common/Calendar/Event.js +25 -0
- data/webpack/components/common/Calendar/Month/Day.js +51 -0
- data/webpack/components/common/Calendar/Month/Header.js +77 -0
- data/webpack/components/common/Calendar/Month/Month.js +47 -0
- data/webpack/components/common/Calendar/Month/index.js +1 -0
- data/webpack/components/common/Calendar/View.js +20 -0
- data/webpack/components/common/Calendar/Week/index.js +13 -0
- data/webpack/components/common/Calendar/index.js +2 -0
- data/webpack/components/common/Terminal/OutputLine.js +26 -0
- data/webpack/components/common/Terminal/Terminal.js +115 -0
- data/webpack/components/common/Terminal/Terminal.scss +47 -0
- data/webpack/index.js +20 -0
- metadata +438 -0
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
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
|
+
require 'rake-version'
|
16
|
+
|
17
|
+
RakeVersion::Tasks.new do |version|
|
18
|
+
version.copy 'lib/foreman_patch/version.rb'
|
19
|
+
end
|
20
|
+
|
21
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
22
|
+
rdoc.rdoc_dir = 'rdoc'
|
23
|
+
rdoc.title = 'ForemanPatch'
|
24
|
+
rdoc.options << '--line-numbers'
|
25
|
+
rdoc.rdoc_files.include('README.rdoc')
|
26
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
|
+
end
|
28
|
+
|
29
|
+
APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
|
30
|
+
|
31
|
+
Bundler::GemHelper.install_tasks
|
32
|
+
|
33
|
+
require 'rake/testtask'
|
34
|
+
|
35
|
+
Rake::TestTask.new(:test) do |t|
|
36
|
+
t.libs << 'lib'
|
37
|
+
t.libs << 'test'
|
38
|
+
t.pattern = 'test/**/*_test.rb'
|
39
|
+
t.verbose = false
|
40
|
+
end
|
41
|
+
|
42
|
+
task default: :test
|
43
|
+
|
44
|
+
begin
|
45
|
+
require 'rubocop/rake_task'
|
46
|
+
RuboCop::RakeTask.new
|
47
|
+
rescue => _
|
48
|
+
puts 'Rubocop not loaded.'
|
49
|
+
end
|
50
|
+
|
51
|
+
task :default do
|
52
|
+
Rake::Task['rubocop'].execute
|
53
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
function remove_window_plan(window_plan_id) {
|
2
|
+
$('#windowPlan' + window_plan_id).remove();
|
3
|
+
}
|
4
|
+
|
5
|
+
function edit_window_plan(window_plan_id) {
|
6
|
+
if (window_plan_id == null) form = null;
|
7
|
+
else form = $('#windowPlans #windowPlanHidden' + window_plan_id);
|
8
|
+
//show_window_plan_modal();
|
9
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module ForemanPatch
|
2
|
+
module Parameters
|
3
|
+
module TicketField
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
include Foreman::Controller::Parameters::LookupKey
|
6
|
+
|
7
|
+
class_methods do
|
8
|
+
def ticket_field_params_filter
|
9
|
+
Foreman::ParameterFilter.new(ForemanPatch::TicketField).tap do |filter|
|
10
|
+
filter.permit_by_context :required, nested: true
|
11
|
+
filter.permit_by_context :id, ui: false, api: false, nested: true
|
12
|
+
|
13
|
+
add_lookup_key_params_filter(filter)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def ticket_field_params
|
19
|
+
self.class.ticket_field_params_filter.filter_params(
|
20
|
+
params,
|
21
|
+
parameter_filter_context
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module ForemanPatch
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class CyclesController < BaseController
|
5
|
+
|
6
|
+
resource_description do
|
7
|
+
resource_id 'patch_cycles'
|
8
|
+
api_version 'v2'
|
9
|
+
api_base_url '/foreman_patch/api'
|
10
|
+
end
|
11
|
+
|
12
|
+
before_action :find_optional_nested_object
|
13
|
+
before_action :find_resource, only: [:show, :update, :destroy]
|
14
|
+
|
15
|
+
api :GET, '/cycles', N_('List cycles')
|
16
|
+
api :GET, '/plans/:plan_id/cycles', N_('List cycles created from cycle plan')
|
17
|
+
param :plan_id, Integer, desc: N_('ID of the cycle plan')
|
18
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
19
|
+
add_scoped_search_description_for(Cycle)
|
20
|
+
def index
|
21
|
+
@cycles = resource_scope_for_index
|
22
|
+
end
|
23
|
+
|
24
|
+
api :GET, '/cycles/:id', N_('Show cycle details')
|
25
|
+
param :id, :identifier, desc: N_('Id of the group'), required: true
|
26
|
+
def show
|
27
|
+
end
|
28
|
+
|
29
|
+
def_param_group :cycle do
|
30
|
+
param :cycle, Hash, required: true, action_aware: true do
|
31
|
+
param :name, String, desc: N_('Name of the patch cycle')
|
32
|
+
param :description, String, desc: N_('Description of the patch cycle')
|
33
|
+
param :start_date, Date, desc: N_('Start date of the patch cycle'), required: true
|
34
|
+
param :end_date, Date, desc: N_('End date of the patch cycle'), required: true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
api :POST, '/plans/:plan_id/cycle', N_('Create a new patch cycle')
|
39
|
+
api :POST, '/cycles', N_('Create a new patch cycle')
|
40
|
+
param :plan_id, Integer, desc: N_('Id of the cycle plan')
|
41
|
+
param_group :cycle, as: :create
|
42
|
+
def create
|
43
|
+
@cycle = Cycle.new(cycle_params)
|
44
|
+
process_response @cycle.save
|
45
|
+
end
|
46
|
+
|
47
|
+
api :PUT, '/cycles/:id', N_('Update a patch cycle')
|
48
|
+
param_group :cycle
|
49
|
+
def update
|
50
|
+
process_response @cycle.update(cycle_params)
|
51
|
+
end
|
52
|
+
|
53
|
+
api :DELETE, '/plans/:id', N_('Destroy a cycle plan')
|
54
|
+
param :id, Integer, desc: N_('Id of the cycle plan')
|
55
|
+
def destroy
|
56
|
+
process_response @cycle.destroy
|
57
|
+
end
|
58
|
+
|
59
|
+
def resource_class
|
60
|
+
ForemanPatch::Cycle
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def allowed_nested_id
|
66
|
+
%w(plan_id)
|
67
|
+
end
|
68
|
+
|
69
|
+
def cycle_params
|
70
|
+
params[:cycle][:plan_id] = params[:plan_id] unless params[:plan_id].nil?
|
71
|
+
params.require(:cycle).permit(:name, :description, :start_date, :plan_id)
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module ForemanPatch
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class GroupsController < BaseController
|
5
|
+
|
6
|
+
resource_description do
|
7
|
+
resource_id 'patch_groups'
|
8
|
+
api_version 'v2'
|
9
|
+
api_base_url '/foreman_patch/api'
|
10
|
+
end
|
11
|
+
|
12
|
+
before_action :find_resource, only: [:update, :show, :destroy]
|
13
|
+
|
14
|
+
api :GET, '/groups', N_('List groups')
|
15
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
16
|
+
add_scoped_search_description_for(Group)
|
17
|
+
def index
|
18
|
+
@groups = resource_scope_for_index
|
19
|
+
end
|
20
|
+
|
21
|
+
api :GET, '/groups/:id', 'Show group details'
|
22
|
+
param :id, :identifier, desc: 'Id of the group', required: true
|
23
|
+
def show
|
24
|
+
end
|
25
|
+
|
26
|
+
def_param_group :group do
|
27
|
+
param :group, Hash, required: true, action_aware: true do
|
28
|
+
param :name, String, desc: N_('Name of the patch group'), required: true
|
29
|
+
param :description, String, desc: N_('Description of the patch group')
|
30
|
+
param :default_window_plan_id, Integer, desc: N_('ID of the default window plan')
|
31
|
+
param :max_unavailable, Integer, desc: N_('Maximum number of hosts that can be patched at a time')
|
32
|
+
param :priority, Integer, desc: N_('Default priority of group within its window (Lowest goes first)')
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
api :POST, '/groups', N_('Create a new patch group')
|
37
|
+
param_group :group, as: :create
|
38
|
+
def create
|
39
|
+
@group = Group.new(group_params)
|
40
|
+
process_response @group.save
|
41
|
+
end
|
42
|
+
|
43
|
+
api :PUT, '/groups/:id', N_('Update a patch group')
|
44
|
+
param :id, Integer, desc: N_('ID of the group'), required: true
|
45
|
+
param_group :group
|
46
|
+
def update
|
47
|
+
process_response @group.update(group_params)
|
48
|
+
end
|
49
|
+
|
50
|
+
api :DELETE, '/groups/:id', N_('Destroy a patch group')
|
51
|
+
param :id, Integer, desc: N_('ID of the group'), required: true
|
52
|
+
def destroy
|
53
|
+
process_response @group.destroy
|
54
|
+
end
|
55
|
+
|
56
|
+
def resource_class
|
57
|
+
ForemanPatch::Group
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def group_params
|
63
|
+
params.require(:group).permit(:name, :description, :default_window_plan_id, :max_unavailable, :priority, :template_id)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ForemanPatch
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class HostGroupsController < BaseController
|
5
|
+
def_param_group :group_facet_attributes do
|
6
|
+
param :group_id, Integer, desc: N_('Id of the default patch group')
|
7
|
+
param :schedule, ['all', 'future-only', 'none'], desc: N_('Schedule host for patching on update, defaults to future-only')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module ForemanPatch
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class InvocationsController < BaseController
|
5
|
+
|
6
|
+
resource_description do
|
7
|
+
resource_id 'patch_invocations'
|
8
|
+
api_version 'v2'
|
9
|
+
api_base_url '/foreman_patch/api'
|
10
|
+
end
|
11
|
+
|
12
|
+
before_action :find_round, only: [:index]
|
13
|
+
before_action :find_resource, only: [:show, :update, :delete]
|
14
|
+
|
15
|
+
api :GET, '/rounds/:round_id/invocations', N_('List patch invocations for a patch group')
|
16
|
+
param :round_id, :identifier, required: true
|
17
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
18
|
+
add_scoped_search_description_for(Invocation)
|
19
|
+
def index
|
20
|
+
@invocations = resource_scope_for_index
|
21
|
+
end
|
22
|
+
|
23
|
+
api :GET, '/invocations/:id', N_('Get details of an invocation')
|
24
|
+
param :id, :identifier, required: true
|
25
|
+
def show
|
26
|
+
@invocation = ForemanPatch::Invocation.find(params[:id])
|
27
|
+
end
|
28
|
+
|
29
|
+
api :PUT, '/invocations/:id', N_('Move the invocation to another round')
|
30
|
+
param :id, :identifier, required: true
|
31
|
+
param :invocation, Hash, required: true do
|
32
|
+
param :round_id, Integer, required: true
|
33
|
+
end
|
34
|
+
def update
|
35
|
+
process_response @invocation.update(invocation_params)
|
36
|
+
end
|
37
|
+
|
38
|
+
api :DELETE, 'invocations/:id', N_('Delete the patch invocation')
|
39
|
+
param :id, :identifier, required: true
|
40
|
+
def destroy
|
41
|
+
process_response @invocation.destroy
|
42
|
+
end
|
43
|
+
|
44
|
+
def resource_class
|
45
|
+
ForemanPatch::Invocation
|
46
|
+
end
|
47
|
+
|
48
|
+
def resource_scope(options = {})
|
49
|
+
if action_name == 'index'
|
50
|
+
@round.invocations.includes(:host).where(host: ::Host.authorized(:view_hosts, ::Host))
|
51
|
+
else
|
52
|
+
super(options)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def find_round
|
59
|
+
@round ||= ForemanPatch::Round.find(params[:round_id])
|
60
|
+
end
|
61
|
+
|
62
|
+
def invocation_params
|
63
|
+
params.require(:invocation).permit(:round_id)
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module ForemanPatch
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class PlansController < BaseController
|
5
|
+
|
6
|
+
resource_description do
|
7
|
+
resource_id 'patch_plans'
|
8
|
+
api_version 'v2'
|
9
|
+
api_base_url '/foreman_patch/api'
|
10
|
+
end
|
11
|
+
|
12
|
+
before_action :find_resource, only: [:show, :update, :iterate, :destroy]
|
13
|
+
|
14
|
+
api :GET, '/plans', N_('List cycle plans')
|
15
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
16
|
+
add_scoped_search_description_for(Plan)
|
17
|
+
def index
|
18
|
+
@plans = resource_scope_for_index
|
19
|
+
end
|
20
|
+
|
21
|
+
api :GET, '/plans/:id', 'Show cycle plan details'
|
22
|
+
param :id, :identifier, desc: 'Id of the group'
|
23
|
+
def show
|
24
|
+
end
|
25
|
+
|
26
|
+
def_param_group :plan do
|
27
|
+
param :plan, Hash, required: true, action_aware: true do
|
28
|
+
param :name, String, desc: N_('Name of the cycle plan'), required: true
|
29
|
+
param :description, String, desc: N_('Description of the cycle plan')
|
30
|
+
param :cycle_name, String, desc: N_('Erb script used to generate each cycle\'s name')
|
31
|
+
param :start_date, String, desc: N_('Date of the first execution of cycle plan'), required: true
|
32
|
+
param :interval, Integer, desc: N_('Number of units between cycles'), required: true
|
33
|
+
param :units, Plan::UNITS, desc: N_('Unit of count between cycles'), required: true
|
34
|
+
param :correction, Plan::CORRECTIONS, desc: N_('Correction applied to each start date')
|
35
|
+
param :active_count, Integer, desc: N_('Number of cycles to have active/planned'), required: true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
api :POST, '/plans', 'Create a new cycle plan'
|
40
|
+
param_group :plan, as: :create
|
41
|
+
def create
|
42
|
+
@plan = Plan.new(plan_params)
|
43
|
+
process_response @plan.save
|
44
|
+
end
|
45
|
+
|
46
|
+
api :PUT, '/plans/:id', N_('Update a cycle plan')
|
47
|
+
param :id, Integer, desc: N_('Id of cycle plan'), required: true
|
48
|
+
param_group :plan
|
49
|
+
def update
|
50
|
+
process_response @plan.update(plan_params)
|
51
|
+
end
|
52
|
+
|
53
|
+
api :POST, '/plans/:id/iterate', N_('Manually iterate a cycle plan')
|
54
|
+
param :id, Integer, desc: N_('Id of cycle plan'), required: true
|
55
|
+
def iterate
|
56
|
+
process_response @plan.iterate
|
57
|
+
end
|
58
|
+
|
59
|
+
api :DELETE, '/plans/:id', N_('Destroy a cycle plan')
|
60
|
+
param :id, Integer, desc: N_('Id of the cycle plan')
|
61
|
+
def destroy
|
62
|
+
process_response @plan.destroy
|
63
|
+
end
|
64
|
+
|
65
|
+
def resource_class
|
66
|
+
ForemanPatch::Plan
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def plan_params
|
72
|
+
params.require(:plan).permit(:name, :description, :cycle_name, :start_date, :interval, :units, :correction, :active_count)
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module ForemanPatch
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class RoundsController < BaseController
|
5
|
+
|
6
|
+
resource_description do
|
7
|
+
resource_id 'patch_rounds'
|
8
|
+
api_version 'v2'
|
9
|
+
api_base_url '/foreman_patch/api'
|
10
|
+
end
|
11
|
+
|
12
|
+
before_action :find_resource, only: [:update, :show, :status, :update, :destroy]
|
13
|
+
|
14
|
+
api :GET, '/rounds', N_('List rounds')
|
15
|
+
api :GET, '/windows/:window_id/rounds'. N_('List window groups within a given window')
|
16
|
+
param :window_id, :identifier
|
17
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
18
|
+
add_scoped_search_description_for(Round)
|
19
|
+
def index
|
20
|
+
@rounds = resource_scope_for_index(params.permit(:window_id))
|
21
|
+
end
|
22
|
+
|
23
|
+
api :GET, '/rounds/:id', 'Show round details'
|
24
|
+
param :id, :identifier, desc: 'Id of the round', required: true
|
25
|
+
def show
|
26
|
+
end
|
27
|
+
|
28
|
+
api :GET, '/rounds/:id/status', N_('Get status of patch round')
|
29
|
+
param :id, :identifier, desc: N_('Id of the patch round'), required: true
|
30
|
+
def status
|
31
|
+
end
|
32
|
+
|
33
|
+
def_param_group :round do
|
34
|
+
param :round, Hash, required: true, action_aware: true do
|
35
|
+
param :name, String, desc: N_('Name of the patch round'), required: true
|
36
|
+
param :description, String, desc: N_('Description of the patch round')
|
37
|
+
param :window_id, Integer, desc: N_('ID of the window'), required: true
|
38
|
+
param :group_id, Integer, desc: N_('ID of the Group')
|
39
|
+
param :max_unavailable, Integer, desc: N_('Maximum number of hosts that can be patched at a time')
|
40
|
+
param :priority, Integer, desc: N_('Default priority of round within its window (Lowest goes first)')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
api :POST, '/rounds', N_('Create a new patch round')
|
45
|
+
param_group :round, as: :create
|
46
|
+
def create
|
47
|
+
@round = Round.new(round_params)
|
48
|
+
process_response @round.save
|
49
|
+
end
|
50
|
+
|
51
|
+
api :PUT, '/rounds/:id', N_('Update a patch round')
|
52
|
+
param :id, Integer, desc: N_('ID of the round'), required: true
|
53
|
+
param_group :round
|
54
|
+
def update
|
55
|
+
process_response @round.update(round_params)
|
56
|
+
end
|
57
|
+
|
58
|
+
api :DELETE, '/rounds/:id', N_('Destroy a patch round')
|
59
|
+
param :id, Integer, desc: N_('ID of the round'), required: true
|
60
|
+
def destroy
|
61
|
+
process_response @round.destroy
|
62
|
+
end
|
63
|
+
|
64
|
+
def resource_class
|
65
|
+
ForemanPatch::Round
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def round_params
|
71
|
+
params.require(:round).permit(:name, :description, :window_id, :group_id, :max_unavailable, :priority)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module ForemanPatch
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class WindowPlansController < BaseController
|
5
|
+
|
6
|
+
resource_description do
|
7
|
+
resource_id 'patch_window_plans'
|
8
|
+
api_version 'v2'
|
9
|
+
api_base_url '/foreman_patch/api'
|
10
|
+
end
|
11
|
+
|
12
|
+
before_action :find_resource, only: [:show, :update, :destroy]
|
13
|
+
|
14
|
+
api :GET, '/plans/:plan_id/window_plans', N_('List window plans per cycle plan')
|
15
|
+
param :plan_id, Integer, desc: N_('ID of the cycle plan')
|
16
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
17
|
+
add_scoped_search_description_for(WindowPlan)
|
18
|
+
def index
|
19
|
+
@window_plans = resource_scope_for_index(params.permit(:plan_id))
|
20
|
+
end
|
21
|
+
|
22
|
+
api :GET, '/window_plans/:id', 'Show window plan details'
|
23
|
+
param :id, :identifier, desc: 'Id of the group'
|
24
|
+
def show
|
25
|
+
end
|
26
|
+
|
27
|
+
def_param_group :window_plan do
|
28
|
+
param :window_plan, Hash, required: true, action_aware: true do
|
29
|
+
param :name, String, desc: N_('Name of the window plan'), required: true
|
30
|
+
param :description, String, desc: N_('Description of the window plan')
|
31
|
+
param :start_day, Integer, desc: N_('Day of execution of the window plan relative to cycle start'), required: true
|
32
|
+
param :start_time, String, desc: N_('Number of windows to have active/planned'), required: true
|
33
|
+
param :duration, Integer, desc: N_('Duration of the patch window in seconds'), required: true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
api :POST, '/plans/:plan_id/window_plans', 'Create a new window plan'
|
38
|
+
param :plan_id, Integer, desc: N_('Id of plan')
|
39
|
+
param_group :window_plan, as: :create
|
40
|
+
def create
|
41
|
+
@window_plan = WindowPlan.new(window_plan_params)
|
42
|
+
process_response @window_plan.save
|
43
|
+
end
|
44
|
+
|
45
|
+
api :PUT, '/window_plans/:id', N_('Update a window plan')
|
46
|
+
param :id, Integer, desc: N_('Id of window plan')
|
47
|
+
param_group :window_plan
|
48
|
+
def update
|
49
|
+
process_response @window_plan.update(window_plan_params)
|
50
|
+
end
|
51
|
+
|
52
|
+
api :DELETE, '/window_plans/:id', N_('Destroy a window plan')
|
53
|
+
param :id, Integer, desc: N_('Id of the window plan')
|
54
|
+
def destroy
|
55
|
+
process_response @window_plan.destroy
|
56
|
+
end
|
57
|
+
|
58
|
+
def resource_class
|
59
|
+
ForemanPatch::WindowPlan
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def window_plan_params
|
65
|
+
params[:window_plan][:plan_id] = params[:plan_id] unless params[:plan_id].nil?
|
66
|
+
params.require(:window_plan).permit(:name, :description, :start_day, :start_time, :duration, :plan_id)
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module ForemanPatch
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class WindowsController < BaseController
|
5
|
+
|
6
|
+
resource_description do
|
7
|
+
resource_id 'patch_windows'
|
8
|
+
api_version 'v2'
|
9
|
+
api_base_url '/foreman_patch/api'
|
10
|
+
end
|
11
|
+
|
12
|
+
before_action :find_resource, only: [:show, :update, :destroy]
|
13
|
+
|
14
|
+
api :GET, '/cycles/:cycle_id/windows', N_('List windows from cycle')
|
15
|
+
param :cycle_id, Integer, desc: N_('ID of the cycle')
|
16
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
17
|
+
add_scoped_search_description_for(Window)
|
18
|
+
def index
|
19
|
+
@windows = resource_scope_for_index(params.permit(:cycle_id))
|
20
|
+
end
|
21
|
+
|
22
|
+
api :GET, '/windows/:id', 'Show window details'
|
23
|
+
param :id, Integer, desc: N_('ID of the window'), required: true
|
24
|
+
def show
|
25
|
+
end
|
26
|
+
|
27
|
+
def_param_group :window do
|
28
|
+
param :window, Hash, required: true, action_aware: true do
|
29
|
+
param :name, String, desc: N_('Name of the patch window'), required: true
|
30
|
+
param :description, String, desc: N_('Description of the patch window')
|
31
|
+
param :window_plan_id, Integer, desc: N_('ID of the window plan to execute')
|
32
|
+
param :start_at, Time, desc: N_('Start time of the patch window'), required: true
|
33
|
+
param :end_by, Time, desc: N_('End time of the patch window'), required: true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
api :POST, '/cycles/:cycle_id/windows', N_('Create a new patch window')
|
38
|
+
param :cycle_id, Integer, N_('ID of the patch cycle'), required: true
|
39
|
+
param_group :window, as: :create
|
40
|
+
def create
|
41
|
+
@window = Window.new(window_params)
|
42
|
+
process_response @window.save
|
43
|
+
end
|
44
|
+
|
45
|
+
api :PUT, '/windows/:id', N_('Update a window')
|
46
|
+
param :id, Integer, desc: N_('ID of the window')
|
47
|
+
param_group :window
|
48
|
+
def update
|
49
|
+
process_response @window.update(window_params)
|
50
|
+
end
|
51
|
+
|
52
|
+
api :DELETE, '/windows/:id', N_('Destroy a window')
|
53
|
+
param :id, Integer, desc: N_('ID of the window')
|
54
|
+
def destroy
|
55
|
+
process_response @window.destroy
|
56
|
+
end
|
57
|
+
|
58
|
+
api :POST, '/windows/:id/schedule', N_('Schedule a window')
|
59
|
+
param :id, Integer, desc: N_('ID of the window')
|
60
|
+
def schedule
|
61
|
+
::ForemanTasks.delay(::Actions::ForemanPatch::Window::Patch, delay_options, @window)
|
62
|
+
end
|
63
|
+
|
64
|
+
def resource_class
|
65
|
+
ForemanPatch::Window
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def delay_options
|
71
|
+
{
|
72
|
+
start_at: @window.start_at.utc,
|
73
|
+
end_by: @window.end_by.try(:utc)
|
74
|
+
}
|
75
|
+
end
|
76
|
+
|
77
|
+
def window_params
|
78
|
+
params[:window][:cycle_id] = params[:cycle_id] unless params[:cycle_id].nil?
|
79
|
+
params.require(:window).permit(:name, :description, :start_at, :end_by, :cycle_id, :window_plan_id)
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|