foreman_puppet 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +619 -0
- data/README.md +38 -0
- data/Rakefile +31 -0
- data/app/assets/stylesheets/foreman_puppet.scss +117 -0
- data/app/controllers/concerns/foreman_puppet/api/import_puppetclasses_common_controller.rb +139 -0
- data/app/controllers/concerns/foreman_puppet/environments_import.rb +61 -0
- data/app/controllers/concerns/foreman_puppet/extensions/api_hostgroups_controller.rb +40 -0
- data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +23 -0
- data/app/controllers/concerns/foreman_puppet/extensions/api_v2_hosts_controller.rb +48 -0
- data/app/controllers/concerns/foreman_puppet/extensions/hostgroups_controller_extensions.rb +58 -0
- data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +228 -0
- data/app/controllers/concerns/foreman_puppet/extensions/operatingsystems_controller.rb +11 -0
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_host.rb +75 -0
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb +70 -0
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_template_combination.rb +21 -0
- data/app/controllers/concerns/foreman_puppet/parameters/config_group.rb +17 -0
- data/app/controllers/concerns/foreman_puppet/parameters/environment.rb +21 -0
- data/app/controllers/concerns/foreman_puppet/parameters/puppetclass.rb +24 -0
- data/app/controllers/concerns/foreman_puppet/parameters/puppetclass_lookup_key.rb +24 -0
- data/app/controllers/foreman_puppet/api/v2/base_controller.rb +26 -0
- data/app/controllers/foreman_puppet/api/v2/config_groups_controller.rb +57 -0
- data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +91 -0
- data/app/controllers/foreman_puppet/api/v2/host_classes_controller.rb +59 -0
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +46 -0
- data/app/controllers/foreman_puppet/api/v2/lookups_common_controller.rb +114 -0
- data/app/controllers/foreman_puppet/api/v2/override_values_controller.rb +99 -0
- data/app/controllers/foreman_puppet/api/v2/puppetclasses_controller.rb +99 -0
- data/app/controllers/foreman_puppet/api/v2/smart_class_parameters_controller.rb +76 -0
- data/app/controllers/foreman_puppet/config_groups_controller.rb +46 -0
- data/app/controllers/foreman_puppet/environments_controller.rb +51 -0
- data/app/controllers/foreman_puppet/puppet_smart_proxies_controller.rb +39 -0
- data/app/controllers/foreman_puppet/puppetclass_lookup_keys_controller.rb +33 -0
- data/app/controllers/foreman_puppet/puppetclasses_controller.rb +113 -0
- data/app/controllers/foreman_puppet/react_controller.rb +19 -0
- data/app/helpers/concerns/foreman_puppet/template_renderer_scope.rb +14 -0
- data/app/helpers/foreman_puppet/environments_helper.rb +17 -0
- data/app/helpers/foreman_puppet/hosts_and_hostgroups_helper.rb +96 -0
- data/app/helpers/foreman_puppet/hosts_helper.rb +32 -0
- data/app/helpers/foreman_puppet/puppet_smart_proxies_helper.rb +8 -0
- data/app/helpers/foreman_puppet/puppetclass_lookup_keys_helper.rb +135 -0
- data/app/helpers/foreman_puppet/puppetclasses_and_environments_helper.rb +55 -0
- data/app/helpers/foreman_puppet/puppetclasses_helper.rb +59 -0
- data/app/helpers/foreman_puppet/template_combinations_helper.rb +33 -0
- data/app/models/concerns/foreman_puppet/extensions/host.rb +88 -0
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +40 -0
- data/app/models/concerns/foreman_puppet/extensions/nic_managed.rb +11 -0
- data/app/models/concerns/foreman_puppet/extensions/operatingsystem.rb +11 -0
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +64 -0
- data/app/models/concerns/foreman_puppet/extensions/report.rb +11 -0
- data/app/models/concerns/foreman_puppet/extensions/taxonomy.rb +19 -0
- data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +23 -0
- data/app/models/concerns/foreman_puppet/extensions/user.rb +22 -0
- data/app/models/concerns/foreman_puppet/host_common.rb +90 -0
- data/app/models/concerns/foreman_puppet/puppet_lookup_value_extensions.rb +13 -0
- data/app/models/foreman_puppet/config_group.rb +45 -0
- data/app/models/foreman_puppet/config_group_class.rb +19 -0
- data/app/models/foreman_puppet/environment.rb +63 -0
- data/app/models/foreman_puppet/environment_class.rb +40 -0
- data/app/models/foreman_puppet/host_class.rb +23 -0
- data/app/models/foreman_puppet/host_config_group.rb +15 -0
- data/app/models/foreman_puppet/host_puppet_facet.rb +130 -0
- data/app/models/foreman_puppet/hostgroup_class.rb +23 -0
- data/app/models/foreman_puppet/hostgroup_puppet_facet.rb +98 -0
- data/app/models/foreman_puppet/puppetclass.rb +132 -0
- data/app/models/foreman_puppet/puppetclass_lookup_key.rb +58 -0
- data/app/services/foreman_puppet/host_info_providers/config_groups_info.rb +10 -0
- data/app/services/foreman_puppet/host_info_providers/puppet_info.rb +92 -0
- data/app/services/foreman_puppet/input_type/puppet_parameter_input.rb +35 -0
- data/app/services/foreman_puppet/proxy_status/puppet.rb +17 -0
- data/app/services/foreman_puppet/puppet_class_importer.rb +355 -0
- data/app/views/api/v2/template_combinations/base.json.erb +9 -0
- data/app/views/foreman_puppet/api/v2/config_groups/base.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/config_groups/create.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/config_groups/index.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/config_groups/main.json.rabl +8 -0
- data/app/views/foreman_puppet/api/v2/config_groups/show.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/config_groups/update.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/environments/base.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/environments/create.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/environments/index.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/environments/main.json.rabl +5 -0
- data/app/views/foreman_puppet/api/v2/environments/show.json.rabl +15 -0
- data/app/views/foreman_puppet/api/v2/environments/update.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/host_puppet_facets/base.json.rabl +1 -0
- data/app/views/foreman_puppet/api/v2/host_puppet_facets/host_single.json.rabl +17 -0
- data/app/views/foreman_puppet/api/v2/host_puppet_facets/show.json.rabl +11 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/base.json.rabl +5 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_single.json.rabl +16 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/show.json.rabl +11 -0
- data/app/views/foreman_puppet/api/v2/import_puppetclasses/index.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/import_puppetclasses/show.json.rabl +36 -0
- data/app/views/foreman_puppet/api/v2/override_values/create.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/override_values/index.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/override_values/show.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/override_values/update.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/base.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/create.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/index.json.rabl +4 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/list.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/main.json.rabl +5 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/show.json.rabl +15 -0
- data/app/views/foreman_puppet/api/v2/puppetclasses/update.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/base.json.rabl +4 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/create.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/destroy.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/index.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/main.json.rabl +23 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/show.json.rabl +19 -0
- data/app/views/foreman_puppet/api/v2/smart_class_parameters/update.json.rabl +3 -0
- data/app/views/foreman_puppet/config_groups/_config_group.html.erb +34 -0
- data/app/views/foreman_puppet/config_groups/_config_groups_selection.html.erb +36 -0
- data/app/views/foreman_puppet/config_groups/_form.html.erb +9 -0
- data/app/views/foreman_puppet/config_groups/edit.html.erb +3 -0
- data/app/views/foreman_puppet/config_groups/index.html.erb +31 -0
- data/app/views/foreman_puppet/config_groups/new.html.erb +3 -0
- data/app/views/foreman_puppet/config_groups/welcome.html.erb +12 -0
- data/app/views/foreman_puppet/environments/_form.html.erb +20 -0
- data/app/views/foreman_puppet/environments/edit.html.erb +8 -0
- data/app/views/foreman_puppet/environments/index.html.erb +32 -0
- data/app/views/foreman_puppet/environments/new.html.erb +7 -0
- data/app/views/foreman_puppet/environments/welcome.html.erb +16 -0
- data/app/views/foreman_puppet/layouts/application_react.html.erb +15 -0
- data/app/views/foreman_puppet/puppet_smart_proxies/_dashboard.html.erb +9 -0
- data/app/views/foreman_puppet/puppet_smart_proxies/_environments.html.erb +30 -0
- data/app/views/foreman_puppet/puppetclass_lookup_keys/edit.html.erb +3 -0
- data/app/views/foreman_puppet/puppetclass_lookup_keys/index.html.erb +22 -0
- data/app/views/foreman_puppet/puppetclass_lookup_keys/welcome.html.erb +9 -0
- data/app/views/foreman_puppet/puppetclasses/_class_parameters.html.erb +37 -0
- data/app/views/foreman_puppet/puppetclasses/_class_selection.html.erb +70 -0
- data/app/views/foreman_puppet/puppetclasses/_classes.html.erb +22 -0
- data/app/views/foreman_puppet/puppetclasses/_classes_in_groups.html.erb +5 -0
- data/app/views/foreman_puppet/puppetclasses/_classes_parameters.html.erb +16 -0
- data/app/views/foreman_puppet/puppetclasses/_form.html.erb +62 -0
- data/app/views/foreman_puppet/puppetclasses/_selected_classes.html.erb +4 -0
- data/app/views/foreman_puppet/puppetclasses/edit.html.erb +4 -0
- data/app/views/foreman_puppet/puppetclasses/index.html.erb +47 -0
- data/app/views/hosts/_form_puppet_enc_tab.html.erb +24 -0
- data/app/views/hosts/foreman_puppet/_form_main_tab_fields.html.erb +1 -0
- data/app/views/hosts/select_multiple_environment.html.erb +8 -0
- data/app/views/provisioning_templates/_combination.html.erb +5 -0
- data/app/views/provisioning_templates/_combinations.html.erb +6 -0
- data/app/views/smart_proxies/plugins/_puppet.html.erb +24 -0
- data/config/api_routes.rb +81 -0
- data/config/routes.rb +89 -0
- data/db/migrate/20101121140000_add_environment_to_template_combinations.foreman_puppet.rb +9 -0
- data/db/migrate/20200720123005_migrate_puppet_core_types.foreman_puppet.rb +19 -0
- data/db/migrate/20200722171017_create_host_puppet_facet.foreman_puppet.rb +10 -0
- data/db/migrate/20200803113531_create_hostgroup_puppet_facet.foreman_puppet.rb +10 -0
- data/db/migrate/20200803113803_migrate_environment_to_puppet_facet.foreman_puppet.rb +22 -0
- data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +29 -0
- data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +47 -0
- data/db/migrate_foreman/20090722141107_create_environments.rb +17 -0
- data/db/migrate_foreman/20120905095532_create_environment_classes.rb +15 -0
- data/db/migrate_foreman/20140407161817_create_config_groups.rb +9 -0
- data/db/migrate_foreman/20140407162007_create_config_group_classes.rb +10 -0
- data/db/migrate_foreman/20140407162059_create_host_config_groups.rb +11 -0
- data/db/migrate_foreman/20161205142618_delete_orphaned_smart_class_parameters.rb +10 -0
- data/db/migrate_foreman/20170109115157_fix_lookup_key_auditable_type.rb +15 -0
- data/db/migrate_foreman/20180816134832_cast_lookup_key_values.rb +35 -0
- data/db/migrate_foreman/20181023112532_add_environment_puppetclass_id.rb +7 -0
- data/db/migrate_foreman/20181224174419_add_index_to_environment_class_by_lookup_key_and_puppetclass.rb +6 -0
- data/db/seeds.d/111_puppet_proxy_feature.rb +8 -0
- data/lib/foreman_puppet.rb +10 -0
- data/lib/foreman_puppet/engine.rb +82 -0
- data/lib/foreman_puppet/register.rb +218 -0
- data/lib/foreman_puppet/version.rb +3 -0
- data/lib/tasks/foreman_puppet_tasks.rake +31 -0
- data/locale/Makefile +60 -0
- data/locale/action_names.rb +5 -0
- data/locale/en/foreman_puppet.edit.po +911 -0
- data/locale/en/foreman_puppet.po +690 -0
- data/locale/en/foreman_puppet.po.time_stamp +0 -0
- data/locale/foreman_puppet.pot +1076 -0
- data/locale/gemspec.rb +2 -0
- data/test/controllers/foreman_puppet/api/v2/config_groups_controller_test.rb +28 -0
- data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +346 -0
- data/test/controllers/foreman_puppet/api/v2/host_classes_controller_test.rb +48 -0
- data/test/controllers/foreman_puppet/api/v2/hostgroup_classes_controller_test.rb +41 -0
- data/test/controllers/foreman_puppet/api/v2/hostgroups_controller_test.rb +79 -0
- data/test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb +101 -0
- data/test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb +29 -0
- data/test/controllers/foreman_puppet/api/v2/override_values_controller_test.rb +169 -0
- data/test/controllers/foreman_puppet/api/v2/puppetclasses_controller_test.rb +144 -0
- data/test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb +557 -0
- data/test/controllers/foreman_puppet/api/v2/template_combinations_controller_test.rb +81 -0
- data/test/controllers/foreman_puppet/config_groups_controller_test.rb +47 -0
- data/test/controllers/foreman_puppet/environments_controller_test.rb +230 -0
- data/test/controllers/foreman_puppet/hostgroups_controller_test.rb +72 -0
- data/test/controllers/foreman_puppet/hosts_controller_test.rb +346 -0
- data/test/controllers/foreman_puppet/puppet_smart_proxies_controller_test.rb +29 -0
- data/test/controllers/foreman_puppet/puppetclass_lookup_keys_controller_test.rb +59 -0
- data/test/controllers/foreman_puppet/puppetclasses_controller_test.rb +235 -0
- data/test/controllers/provisioning_templates_controller_test.rb +70 -0
- data/test/factories/foreman_puppet_factories.rb +134 -0
- data/test/factories/host_puppet_enhancements.rb +61 -0
- data/test/factories/proxy_puppet_enhancements.rb +33 -0
- data/test/helpers/foreman_puppet/hosts_and_hostgroups_helper_test.rb +65 -0
- data/test/helpers/foreman_puppet/puppetclasses_helper_test.rb +33 -0
- data/test/integration/foreman_puppet/environment_js_test.rb +27 -0
- data/test/integration/foreman_puppet/host_js_test.rb +371 -0
- data/test/integration/foreman_puppet/hostgroup_js_test.rb +100 -0
- data/test/integration/foreman_puppet/puppetclass_js_test.rb +37 -0
- data/test/integration/foreman_puppet/smartclass_parameter_js_test.rb +84 -0
- data/test/models/foreman_puppet/config_group_class_test.rb +9 -0
- data/test/models/foreman_puppet/config_group_test.rb +8 -0
- data/test/models/foreman_puppet/environment_test.rb +92 -0
- data/test/models/foreman_puppet/host_config_group_test.rb +39 -0
- data/test/models/foreman_puppet/host_puppet_facet_test.rb +116 -0
- data/test/models/foreman_puppet/host_test.rb +288 -0
- data/test/models/foreman_puppet/hostgroup_puppet_facet_test.rb +200 -0
- data/test/models/foreman_puppet/hostgroup_test.rb +14 -0
- data/test/models/foreman_puppet/lookup_value_test.rb +69 -0
- data/test/models/foreman_puppet/provisioning_template_test.rb +124 -0
- data/test/models/foreman_puppet/puppetclass_lookup_key_test.rb +81 -0
- data/test/models/foreman_puppet/puppetclass_test.rb +144 -0
- data/test/models/foreman_puppet/smart_proxy_test.rb +28 -0
- data/test/qraphql/queries/host_puppet_query_test.rb +36 -0
- data/test/qraphql/queries/hostgroup_puppet_query_test.rb +36 -0
- data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +791 -0
- data/test/services/foreman_puppet/input_type/puppet_parameter_input_test.rb +14 -0
- data/test/test_puppet_helper.rb +30 -0
- data/test/unit/foreman_puppet/access_permissions_test.rb +16 -0
- data/test/unit/foreman_puppet/puppet_class_importer_test.rb +247 -0
- data/test/unit/foreman_puppet/template_rendering_test.rb +20 -0
- data/test/unit/foreman_puppet_test.rb +11 -0
- data/webpack/__mocks__/foremanReact/common/I18n.js +7 -0
- data/webpack/__mocks__/foremanReact/components/Layout/LayoutActions.js +2 -0
- data/webpack/__mocks__/foremanReact/readme.md +11 -0
- data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +10 -0
- data/webpack/__mocks__/foremanReact/redux/API/index.js +10 -0
- data/webpack/__mocks__/foremanReact/redux/actions/toasts.js +8 -0
- data/webpack/__mocks__/foremanReact/redux/index.js +1 -0
- data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +5 -0
- data/webpack/fills_index.js +30 -0
- data/webpack/index.js +18 -0
- data/webpack/src/ForemanPuppet.js +11 -0
- data/webpack/src/Router/__snapshots__/routes.test.js.snap +3 -0
- data/webpack/src/Router/index.js +14 -0
- data/webpack/src/Router/routes.js +3 -0
- data/webpack/src/Router/routes.test.js +16 -0
- data/webpack/src/foreman_class_edit.js +224 -0
- data/webpack/src/foreman_puppet_host_form.js +140 -0
- data/webpack/src/foreman_puppet_host_form.test.js +65 -0
- data/webpack/src/index.js +1 -0
- data/webpack/src/reducers.js +7 -0
- metadata +340 -0
@@ -0,0 +1,99 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class OverrideValuesController < LookupsCommonController
|
5
|
+
include Foreman::Controller::Parameters::LookupValue
|
6
|
+
|
7
|
+
resource_description do
|
8
|
+
api_version '2'
|
9
|
+
api_base_url '/foreman_puppet/api'
|
10
|
+
end
|
11
|
+
|
12
|
+
before_action :find_override_values
|
13
|
+
before_action :find_override_value, only: %i[show update destroy]
|
14
|
+
# override return_if_smart_mismatch in LookupKeysCommonController to add :create
|
15
|
+
before_action :return_if_smart_mismatch, only: %i[create show update destroy]
|
16
|
+
before_action :return_if_override_mismatch, only: %i[show update destroy]
|
17
|
+
|
18
|
+
before_action :cast_value, only: %i[create update]
|
19
|
+
|
20
|
+
api :GET, '/smart_class_parameters/:smart_class_parameter_id/override_values', N_('List of override values for a specific smart class parameter')
|
21
|
+
param :smart_class_parameter_id, :identifier, required: false
|
22
|
+
param :show_hidden, :bool, desc: N_('Display hidden values')
|
23
|
+
param_group :pagination, ::Api::V2::BaseController
|
24
|
+
|
25
|
+
def index
|
26
|
+
end
|
27
|
+
|
28
|
+
api :GET, '/smart_class_parameters/:smart_class_parameter_id/override_values/:id', N_('Show an override value for a specific smart class parameter')
|
29
|
+
param :smart_class_parameter_id, :identifier, required: false
|
30
|
+
param :id, :identifier, required: true
|
31
|
+
param :show_hidden, :bool, desc: N_('Display hidden values')
|
32
|
+
|
33
|
+
def show
|
34
|
+
end
|
35
|
+
|
36
|
+
def_param_group :override_value do
|
37
|
+
param :override_value, Hash, required: true, action_aware: true do
|
38
|
+
param :match, String, required: true, desc: N_('Override match')
|
39
|
+
param :value, :any_type, of: LookupKey::KEY_TYPES, required: false, desc: N_('Override value, required if omit is false')
|
40
|
+
param :omit, :bool, required: false, desc: N_('Foreman will not send this parameter in classification output')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
api :POST, '/smart_class_parameters/:smart_class_parameter_id/override_values', N_('Create an override value for a specific smart class parameter')
|
45
|
+
param :smart_class_parameter_id, :identifier, required: false
|
46
|
+
param_group :override_value, as: :create
|
47
|
+
|
48
|
+
def create
|
49
|
+
@override_value = @smart_class_parameter.lookup_values.create!(lookup_value_params)
|
50
|
+
@smart_class_parameter.update(override: true)
|
51
|
+
process_response @override_value
|
52
|
+
end
|
53
|
+
|
54
|
+
api :PUT, '/smart_class_parameters/:smart_class_parameter_id/override_values/:id', N_('Update an override value for a specific smart class parameter')
|
55
|
+
param :smart_class_parameter_id, :identifier, required: false
|
56
|
+
param_group :override_value
|
57
|
+
|
58
|
+
def update
|
59
|
+
@override_value.update!(lookup_value_params)
|
60
|
+
render 'foreman_puppet/api/v2/override_values/show'
|
61
|
+
end
|
62
|
+
|
63
|
+
api :DELETE, '/smart_class_parameters/:smart_class_parameter_id/override_values/:id', N_('Delete an override value for a specific smart class parameter')
|
64
|
+
param :smart_class_parameter_id, :identifier, required: false
|
65
|
+
param :id, :identifier, required: true
|
66
|
+
|
67
|
+
def destroy
|
68
|
+
@override_value.destroy
|
69
|
+
render 'foreman_puppet/api/v2/override_values/show'
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
def find_override_values
|
75
|
+
return unless @smart_class_parameter
|
76
|
+
|
77
|
+
@override_values = @smart_class_parameter.lookup_values.paginate(paginate_options)
|
78
|
+
@total = @override_values.count
|
79
|
+
end
|
80
|
+
|
81
|
+
def find_override_value
|
82
|
+
@override_value = LookupValue.find_by(id: params[:id])
|
83
|
+
@override_value ||= @smart_class_parameter.lookup_values.friendly.find(params[:id]) if @smart_class_parameter
|
84
|
+
end
|
85
|
+
|
86
|
+
def return_if_override_mismatch
|
87
|
+
return unless (@override_values && @override_value && !@override_values.find_by(id: @override_value.id)) || (@override_values && !@override_value) || !@override_values
|
88
|
+
|
89
|
+
not_found "Override value not found by id '#{params[:id]}'"
|
90
|
+
end
|
91
|
+
|
92
|
+
# overwrite Api::BaseController
|
93
|
+
def resource_class
|
94
|
+
LookupValue
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class PuppetclassesController < BaseController
|
5
|
+
include ForemanPuppet::Parameters::Puppetclass
|
6
|
+
|
7
|
+
before_action :find_optional_nested_object
|
8
|
+
before_action :find_resource, only: %w[show update destroy]
|
9
|
+
|
10
|
+
api :GET, '/puppetclasses/', N_('List all Puppet classes')
|
11
|
+
api :GET, '/hosts/:host_id/puppetclasses', N_('List all Puppet classes for a host')
|
12
|
+
api :GET, '/hostgroups/:hostgroup_id/puppetclasses', N_('List all Puppet classes for a host group')
|
13
|
+
api :GET, '/environments/:environment_id/puppetclasses', N_('List all Puppet classes for an environment')
|
14
|
+
param :host_id, String, desc: N_('ID of host')
|
15
|
+
param :hostgroup_id, String, desc: N_('ID of host group')
|
16
|
+
param :environment_id, String, desc: N_('ID of environment')
|
17
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
18
|
+
add_scoped_search_description_for(Puppetclass)
|
19
|
+
|
20
|
+
def index
|
21
|
+
values = Puppetclass.authorized(:view_puppetclasses).search_for(*search_options) unless nested_obj
|
22
|
+
values ||= case nested_obj
|
23
|
+
when Host::Base, Hostgroup
|
24
|
+
# NOTE: no search_for on array generated by all_puppetclasses
|
25
|
+
nested_obj.puppet.all_puppetclasses
|
26
|
+
else
|
27
|
+
nested_obj.puppetclasses.search_for(*search_options)
|
28
|
+
end
|
29
|
+
@total = Puppetclass.count unless nested_obj
|
30
|
+
@total ||= case nested_obj
|
31
|
+
when Host::Base, Hostgroup
|
32
|
+
values.count
|
33
|
+
else
|
34
|
+
nested_obj.puppetclasses.count
|
35
|
+
end
|
36
|
+
@subtotal = values.count
|
37
|
+
if params[:style] == 'list'
|
38
|
+
@puppetclasses = values
|
39
|
+
render :list
|
40
|
+
else
|
41
|
+
@puppetclasses = Puppetclass.classes2hash_v2(values.paginate(paginate_options))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
api :GET, '/puppetclasses/:id', N_('Show a Puppet class')
|
46
|
+
api :GET, '/hosts/:host_id/puppetclasses/:id', N_('Show a Puppet class for host')
|
47
|
+
api :GET, '/hostgroups/:hostgroup_id/puppetclasses/:id', N_('Show a Puppet class for a host group')
|
48
|
+
api :GET, '/environments/:environment_id/puppetclasses/:id', N_('Show a Puppet class for an environment')
|
49
|
+
param :host_id, String, desc: N_('ID of host')
|
50
|
+
param :hostgroup_id, String, desc: N_('ID of host group')
|
51
|
+
param :environment_id, String, desc: N_('ID of environment')
|
52
|
+
param :id, String, required: true, desc: N_('ID of Puppet class')
|
53
|
+
|
54
|
+
def show
|
55
|
+
end
|
56
|
+
|
57
|
+
def_param_group :puppetclass do
|
58
|
+
param :puppetclass, Hash, required: true, action_aware: true do
|
59
|
+
param :name, String, required: true
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
api :POST, '/puppetclasses/', N_('Create a Puppet class')
|
64
|
+
param_group :puppetclass, as: :create
|
65
|
+
|
66
|
+
def create
|
67
|
+
@puppetclass = Puppetclass.new(puppetclass_params)
|
68
|
+
process_response @puppetclass.save
|
69
|
+
end
|
70
|
+
|
71
|
+
api :PUT, '/puppetclasses/:id/', N_('Update a Puppet class')
|
72
|
+
param :id, String, required: true
|
73
|
+
param_group :puppetclass
|
74
|
+
|
75
|
+
def update
|
76
|
+
class_params = puppetclass_params.merge(smart_class_parameter_ids: @puppetclass.smart_class_parameters.map(&:id))
|
77
|
+
process_response @puppetclass.update(class_params)
|
78
|
+
end
|
79
|
+
|
80
|
+
api :DELETE, '/puppetclasses/:id/', N_('Delete a Puppet class')
|
81
|
+
param :id, String, required: true
|
82
|
+
|
83
|
+
def destroy
|
84
|
+
process_response @puppetclass.destroy
|
85
|
+
end
|
86
|
+
|
87
|
+
def resource_class
|
88
|
+
ForemanPuppet::Puppetclass
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def allowed_nested_id
|
94
|
+
%w[environment_id host_id hostgroup_id]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
module Api
|
3
|
+
module V2
|
4
|
+
class SmartClassParametersController < ForemanPuppet::Api::V2::LookupsCommonController
|
5
|
+
include ForemanPuppet::Parameters::PuppetclassLookupKey
|
6
|
+
|
7
|
+
resource_description do
|
8
|
+
api_version '2'
|
9
|
+
api_base_url '/foreman_puppet/api'
|
10
|
+
end
|
11
|
+
|
12
|
+
alias_method :resource_scope, :smart_class_parameters_resource_scope
|
13
|
+
|
14
|
+
api :GET, '/smart_class_parameters', N_('List all smart class parameters')
|
15
|
+
api :GET, '/hosts/:host_id/smart_class_parameters', N_('List of smart class parameters for a specific host')
|
16
|
+
api :GET, '/hostgroups/:hostgroup_id/smart_class_parameters', N_('List of smart class parameters for a specific host group')
|
17
|
+
api :GET, '/puppetclasses/:puppetclass_id/smart_class_parameters', N_('List of smart class parameters for a specific Puppet class')
|
18
|
+
api :GET, '/environments/:environment_id/smart_class_parameters', N_('List of smart class parameters for a specific environment')
|
19
|
+
api :GET, '/environments/:environment_id/puppetclasses/:puppetclass_id/smart_class_parameters',
|
20
|
+
N_('List of smart class parameters for a specific environment/Puppet class combination')
|
21
|
+
param :host_id, :identifier, required: false
|
22
|
+
param :hostgroup_id, :identifier, required: false
|
23
|
+
param :puppetclass_id, :identifier, required: false
|
24
|
+
param :environment_id, :identifier, required: false
|
25
|
+
param :show_hidden, :bool, desc: N_('Display hidden values')
|
26
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
27
|
+
add_scoped_search_description_for(PuppetclassLookupKey)
|
28
|
+
|
29
|
+
def index
|
30
|
+
end
|
31
|
+
|
32
|
+
# no create action for API
|
33
|
+
# smart class parameters are imported by PuppetClassImporter
|
34
|
+
|
35
|
+
api :GET, '/smart_class_parameters/:id/', N_('Show a smart class parameter')
|
36
|
+
param :id, :identifier, required: true
|
37
|
+
param :show_hidden, :bool, desc: N_('Display hidden values')
|
38
|
+
|
39
|
+
def show
|
40
|
+
end
|
41
|
+
|
42
|
+
api :PUT, '/smart_class_parameters/:id', N_('Update a smart class parameter')
|
43
|
+
param :id, :identifier, required: true
|
44
|
+
param :smart_class_parameter, Hash, required: true do
|
45
|
+
# can't update parameter/key name for :parameter, String, :required => true
|
46
|
+
param :override, :bool, desc: N_('Whether the smart class parameter value is managed by Foreman')
|
47
|
+
param :description, String, desc: N_('Description of smart class')
|
48
|
+
param :default_value, :any_type, of: LookupKey::KEY_TYPES, desc: N_('Value to use when there is no match')
|
49
|
+
param :hidden_value, :bool, desc: N_('When enabled the parameter is hidden in the UI')
|
50
|
+
param :omit, :bool, desc: N_('Foreman will not send this parameter in classification output.'\
|
51
|
+
'Puppet will use the value defined in the Puppet manifest for this parameter')
|
52
|
+
param :path, String, desc: N_('The order in which values are resolved')
|
53
|
+
param :validator_type, LookupKey::VALIDATOR_TYPES, desc: N_('Types of validation values')
|
54
|
+
param :validator_rule, String, desc: N_('Used to enforce certain values for the parameter values')
|
55
|
+
param :override_value_order, String, desc: N_('The order in which values are resolved')
|
56
|
+
param :parameter_type, LookupKey::KEY_TYPES, desc: N_('Types of variable values')
|
57
|
+
param :required, :bool, desc: N_('If true, will raise an error if there is no default value and no matcher provide a value')
|
58
|
+
param :merge_overrides, :bool, desc: N_('Merge all matching values (only array/hash type)')
|
59
|
+
param :merge_default, :bool, desc: N_('Include default value when merging all matching values')
|
60
|
+
param :avoid_duplicates, :bool, desc: N_('Remove duplicate values (only array type)')
|
61
|
+
end
|
62
|
+
|
63
|
+
def update
|
64
|
+
# NOTE: User must manually set :override => true. It is not automatically updated if optional input validator fields are updated.
|
65
|
+
@smart_class_parameter.update!(puppetclass_lookup_key_params)
|
66
|
+
render 'foreman_puppet/api/v2/smart_class_parameters/show'
|
67
|
+
end
|
68
|
+
|
69
|
+
# overwrite Api::BaseController
|
70
|
+
def resource_class
|
71
|
+
LookupKey
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
class ConfigGroupsController < ::ApplicationController
|
3
|
+
include Foreman::Controller::AutoCompleteSearch
|
4
|
+
include ForemanPuppet::Parameters::ConfigGroup
|
5
|
+
|
6
|
+
before_action :find_resource, only: %i[edit update destroy]
|
7
|
+
|
8
|
+
helper PuppetclassesHelper
|
9
|
+
|
10
|
+
def index
|
11
|
+
@config_groups = resource_base_search_and_page
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@config_group = ForemanPuppet::ConfigGroup.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def edit
|
19
|
+
end
|
20
|
+
|
21
|
+
def create
|
22
|
+
@config_group = ForemanPuppet::ConfigGroup.new(config_group_params)
|
23
|
+
if @config_group.save
|
24
|
+
process_success
|
25
|
+
else
|
26
|
+
process_error
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
if @config_group.update(config_group_params)
|
32
|
+
process_success
|
33
|
+
else
|
34
|
+
process_error
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def destroy
|
39
|
+
if @config_group.destroy
|
40
|
+
process_success
|
41
|
+
else
|
42
|
+
process_error
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
class EnvironmentsController < ApplicationController
|
3
|
+
include Foreman::Controller::AutoCompleteSearch
|
4
|
+
include ForemanPuppet::EnvironmentsImport
|
5
|
+
include ForemanPuppet::Parameters::Environment
|
6
|
+
|
7
|
+
before_action :find_resource, only: %i[edit update destroy]
|
8
|
+
|
9
|
+
def index
|
10
|
+
@environments = resource_base_search_and_page
|
11
|
+
# AuthorizerHelper#authorizer uses controller_name as variable name, but it fails with namespaces
|
12
|
+
@authorizer = Authorizer.new(User.current, collection: @environments)
|
13
|
+
end
|
14
|
+
|
15
|
+
def new
|
16
|
+
@environment = model_of_controller.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@environment = model_of_controller.new(environment_params)
|
21
|
+
if @environment.save
|
22
|
+
process_success
|
23
|
+
else
|
24
|
+
process_error
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def edit
|
29
|
+
end
|
30
|
+
|
31
|
+
def update
|
32
|
+
if @environment.update(environment_params)
|
33
|
+
process_success
|
34
|
+
else
|
35
|
+
process_error
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy
|
40
|
+
if @environment.destroy
|
41
|
+
process_success
|
42
|
+
else
|
43
|
+
process_error
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def resource_class
|
48
|
+
model_of_controller
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
class PuppetSmartProxiesController < ApplicationController
|
3
|
+
before_action :find_resource
|
4
|
+
before_action :find_status, only: [:environments]
|
5
|
+
|
6
|
+
def environments
|
7
|
+
render partial: 'foreman_puppet/puppet_smart_proxies/environments', locals: { environments: @proxy_status[:puppet].environment_stats }
|
8
|
+
rescue Foreman::Exception => e
|
9
|
+
process_ajax_error e
|
10
|
+
end
|
11
|
+
|
12
|
+
def dashboard
|
13
|
+
@data = Dashboard::Data.new("puppet_proxy_id = \"#{@smart_proxy.id}\"")
|
14
|
+
render partial: 'foreman_puppet/puppet_smart_proxies/dashboard'
|
15
|
+
rescue Foreman::Exception => e
|
16
|
+
process_ajax_error e
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def find_status
|
22
|
+
@proxy_status = @smart_proxy.statuses
|
23
|
+
end
|
24
|
+
|
25
|
+
def action_permission
|
26
|
+
case params[:action]
|
27
|
+
when 'environments', 'dashboard'
|
28
|
+
:view
|
29
|
+
else
|
30
|
+
super
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def resource_name(resource = controller_name)
|
35
|
+
resource = 'smart_proxies' if resource == 'puppet_smart_proxies'
|
36
|
+
super(resource)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
class PuppetclassLookupKeysController < ::LookupKeysController
|
3
|
+
include Parameters::PuppetclassLookupKey
|
4
|
+
|
5
|
+
before_action :setup_search_options, only: :index
|
6
|
+
|
7
|
+
def index
|
8
|
+
@lookup_keys = resource_base_search_and_page.distinct.preload(:lookup_values)
|
9
|
+
environment_classes = EnvironmentClass.where(puppetclass_lookup_key_id: @lookup_keys.map(&:id)).select(:puppetclass_id, :puppetclass_lookup_key_id).distinct.preload(:puppetclass)
|
10
|
+
puppetclass_ids = environment_classes.map(&:puppetclass_id).uniq
|
11
|
+
@puppetclass_authorizer = Authorizer.new(User.current, collection: puppetclass_ids)
|
12
|
+
@lookup_keys_to_class = Hash[environment_classes.map { |environment_class| [environment_class.puppetclass_lookup_key_id, environment_class.puppetclass] }]
|
13
|
+
end
|
14
|
+
|
15
|
+
def resource_class
|
16
|
+
ForemanPuppet::PuppetclassLookupKey
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def resource
|
22
|
+
@puppetclass_lookup_key
|
23
|
+
end
|
24
|
+
|
25
|
+
def controller_permission
|
26
|
+
'external_parameters'
|
27
|
+
end
|
28
|
+
|
29
|
+
def resource_params
|
30
|
+
puppetclass_lookup_key_params
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|