foreman_puppet 1.0.5 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/app/controllers/concerns/foreman_puppet/extensions/api_hostgroups_controller.rb +14 -16
- data/app/controllers/concerns/foreman_puppet/{api/import_puppetclasses_common_controller.rb → extensions/api_smart_proxies_controller.rb} +16 -5
- data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +23 -1
- data/app/controllers/concerns/foreman_puppet/extensions/api_v2_hosts_controller.rb +15 -17
- data/app/controllers/concerns/foreman_puppet/extensions/hosts_controller_extensions.rb +0 -1
- data/app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb +2 -8
- data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +0 -1
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +1 -1
- data/app/controllers/foreman_puppet/puppetclasses_controller.rb +1 -1
- data/app/helpers/foreman_puppet/environments_helper.rb +1 -1
- data/app/helpers/foreman_puppet/hosts_and_hostgroups_helper.rb +0 -5
- data/app/helpers/foreman_puppet/hosts_helper.rb +6 -10
- data/app/models/concerns/foreman_puppet/extensions/host.rb +2 -16
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +2 -7
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +7 -12
- data/app/models/concerns/foreman_puppet/extensions/template_combination.rb +5 -10
- data/app/services/foreman_puppet/puppet_class_importer.rb +0 -6
- data/app/views/foreman_puppet/api/v2/host_puppet_facets/host_list.json.rabl +3 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/base.json.rabl +2 -0
- data/app/views/foreman_puppet/api/v2/hostgroup_puppet_facets/hostgroup_list.json.rabl +3 -0
- data/app/views/foreman_puppet/config_groups/_config_group.html.erb +5 -1
- data/app/views/foreman_puppet/config_groups/index.html.erb +1 -1
- data/config/api_routes.rb +1 -9
- data/config/initializers/api_reroute.rb +73 -5
- data/db/migrate/20101121140000_add_environment_to_template_combinations.foreman_puppet.rb +1 -1
- data/db/migrate/20200803113803_migrate_environment_to_puppet_facet.foreman_puppet.rb +2 -0
- data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +0 -8
- data/db/migrate/20210924103241_remove_katello_id_from_environments.foreman_puppet.rb +5 -0
- data/db/migrate/20211111125003_drop_puppetclasses_direct_references.foreman_puppet.rb +11 -0
- data/db/migrate_foreman/{20090722141107_create_environments.rb → 20090722141107_create_environments.foreman_puppet.rb} +3 -3
- data/db/migrate_foreman/20090802062223_create_puppetclasses.foreman_puppet.rb +29 -0
- data/db/migrate_foreman/20090905150132_create_hostgroups_puppetclasses.foreman_puppet.rb +12 -0
- data/db/migrate_foreman/20110412103238_remove_unused_fields_from_puppet_classes.foreman_puppet.rb +9 -0
- data/db/migrate_foreman/20110712070522_create_host_class.foreman_puppet.rb +11 -0
- data/db/migrate_foreman/20120824142048_add_some_indexes.foreman_puppet.rb +21 -0
- data/db/migrate_foreman/{20120905095532_create_environment_classes.rb → 20120905095532_create_environment_classes.foreman_puppet.rb} +2 -2
- data/db/migrate_foreman/20121018152459_create_hostgroup_classes.foreman_puppet.rb +11 -0
- data/db/migrate_foreman/{20140407161817_create_config_groups.rb → 20140407161817_create_config_groups.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20140407162007_create_config_group_classes.rb → 20140407162007_create_config_group_classes.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20140407162059_create_host_config_groups.rb → 20140407162059_create_host_config_groups.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/{20161205142618_delete_orphaned_smart_class_parameters.rb → 20161205142618_delete_orphaned_smart_class_parameters.foreman_puppet.rb} +1 -1
- data/db/migrate_foreman/{20170109115157_fix_lookup_key_auditable_type.rb → 20170109115157_fix_lookup_key_auditable_type.foreman_puppet.rb} +0 -0
- data/db/migrate_foreman/20180816134832_cast_lookup_key_values.foreman_puppet.rb +5 -0
- data/db/migrate_foreman/20180831115634_add_uniqueness_to_puppetclass_name.foreman_puppet.rb +24 -0
- data/db/migrate_foreman/{20181023112532_add_environment_puppetclass_id.rb → 20181023112532_add_environment_puppetclass_id.foreman_puppet.rb} +1 -1
- data/db/migrate_foreman/{20181224174419_add_index_to_environment_class_by_lookup_key_and_puppetclass.rb → 20181224174419_add_index_to_environment_class_by_lookup_key_and_puppetclass.foreman_puppet.rb} +0 -0
- data/lib/foreman_puppet/engine.rb +4 -36
- data/lib/foreman_puppet/register.rb +49 -45
- data/lib/foreman_puppet/version.rb +1 -1
- data/lib/foreman_puppet.rb +1 -6
- data/locale/ca/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ca/foreman_puppet.po +760 -0
- data/locale/cs_CZ/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/cs_CZ/foreman_puppet.po +823 -0
- data/locale/de/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/de/foreman_puppet.po +844 -0
- data/locale/en/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en/foreman_puppet.po +119 -8
- data/locale/en_GB/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/en_GB/foreman_puppet.po +820 -0
- data/locale/es/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/es/foreman_puppet.po +827 -0
- data/locale/foreman_puppet.pot +376 -205
- data/locale/fr/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/fr/foreman_puppet.po +835 -0
- data/locale/gemspec.rb +1 -1
- data/locale/gl/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/gl/foreman_puppet.po +818 -0
- data/locale/it/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/it/foreman_puppet.po +822 -0
- data/locale/ja/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ja/foreman_puppet.po +830 -0
- data/locale/ko/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ko/foreman_puppet.po +819 -0
- data/locale/nl_NL/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/nl_NL/foreman_puppet.po +823 -0
- data/locale/pl/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/pl/foreman_puppet.po +822 -0
- data/locale/pt_BR/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/pt_BR/foreman_puppet.po +826 -0
- data/locale/ru/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/ru/foreman_puppet.po +827 -0
- data/locale/sv_SE/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/sv_SE/foreman_puppet.po +822 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/zh_CN/foreman_puppet.po +831 -0
- data/locale/zh_TW/LC_MESSAGES/foreman_puppet.mo +0 -0
- data/locale/zh_TW/foreman_puppet.po +821 -0
- data/package.json +8 -11
- data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +24 -249
- data/test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/api/v2/smart_proxies_controller_test.rb +255 -0
- data/test/controllers/foreman_puppet/environments_controller_test.rb +3 -3
- data/test/controllers/foreman_puppet/hosts_controller_test.rb +0 -1
- data/test/factories/foreman_puppet_factories.rb +0 -2
- data/test/graphql/queries/environment_query_test.rb +4 -4
- data/test/graphql/queries/puppetclass_query_test.rb +4 -4
- data/test/integration/foreman_puppet/dashboard_js_test.rb +30 -0
- data/test/integration/foreman_puppet/environment_js_test.rb +1 -2
- data/test/integration/foreman_puppet/host_js_test.rb +17 -19
- data/test/integration/foreman_puppet/hostgroup_js_test.rb +1 -2
- data/test/integration/foreman_puppet/puppetclass_js_test.rb +2 -3
- data/test/integration/foreman_puppet/smartclass_parameter_js_test.rb +1 -2
- data/test/integration_puppet_helper.rb +3 -0
- data/test/models/foreman_puppet/host_puppet_facet_test.rb +2 -2
- data/test/models/foreman_puppet/host_test.rb +48 -22
- data/test/models/foreman_puppet/provisioning_template_test.rb +3 -3
- data/test/models/foreman_puppet/puppetclass_test.rb +1 -1
- data/test/models/foreman_puppet/user_test.rb +1 -5
- data/test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb +1 -1
- data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +3 -3
- data/test/unit/foreman_puppet/puppet_class_importer_test.rb +1 -1
- data/test/unit/foreman_puppet/template_rendering_test.rb +1 -1
- metadata +66 -15
- data/db/migrate_foreman/20180816134832_cast_lookup_key_values.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 551d9a6cf7153dfc0bb5a4709bbd394bc6d2ba5354b16531de6787653ca1d185
|
4
|
+
data.tar.gz: cacbf35dfb12c49175bd0ee95ea8cf4b441319c140b7401c5527b8231a9000f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c28a424fb8afdb633134b1f57fa7254ead445a7a1e45d3b8bc97cbfc3ffd42a0dbb80df33ae2d7cc52d55cc12575078a773b3ed5ae3b9a360f9afb26d2631b8
|
7
|
+
data.tar.gz: d29c6598e1709bfddceb64e92fe16f33df55ce5eb85288e3f3ad14d590aa59d88515c37fd7116a252d889deb416bb652449c6fa6de3ef4baad5e27bfd9547bc8
|
data/README.md
CHANGED
@@ -37,7 +37,9 @@ You can install it on Foreman 2.5 to prepare for the Foreman update.
|
|
37
37
|
|
38
38
|
|Foreman version|Plugin version|Notes |
|
39
39
|
|---------------|--------------|------------------------------------------|
|
40
|
-
| >= 3.
|
40
|
+
| >= 3.2 | ~> 3.0 | Required |
|
41
|
+
| ~> 3.1 | ~> 2.0 | Required |
|
42
|
+
| ~> 3.0 | ~> 1.0 | Required |
|
41
43
|
| >= 2.5 | ~> 0.1 | Optional; replaces Core features |
|
42
44
|
| < 2.5 | - | Not supported (functionality is in Core) |
|
43
45
|
|
@@ -6,25 +6,23 @@ module ForemanPuppet
|
|
6
6
|
included do
|
7
7
|
prepend PatchMethods
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
method_desc.apis << Apipie::MethodDescription::Api.new(:GET, '/puppetclasses/:puppetclass_id/hostgroups', N_('List all host groups for a Puppet class'), {})
|
9
|
+
method_desc = Apipie.get_method_description(self, :index)
|
10
|
+
method_desc.apis << Apipie::MethodDescription::Api.new(:GET, '/puppetclasses/:puppetclass_id/hostgroups', N_('List all host groups for a Puppet class'), {})
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
apipie_update_methods([:index]) do
|
13
|
+
param :puppetclass_id, String, desc: N_('ID of Puppetclass')
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
apipie_update_methods(%i[create update]) do
|
17
|
+
param :hostgroup, Hash do
|
18
|
+
param :environment_id, String, desc: N_('Deprecated in favor of hostgroup/puppet_attributes/environment_id')
|
19
|
+
param :puppetclass_ids, Array, desc: N_('Deprecated in favor of hostgroup/puppet_attributes/puppetclass_ids')
|
20
|
+
param :config_group_ids, Array, desc: N_('Deprecated in favor of hostgroup/puppet_attributes/config_group_ids')
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
22
|
+
param :puppet_attributes, Hash do
|
23
|
+
param :environment_id, String, desc: N_('ID of associated puppet Environment')
|
24
|
+
param :puppetclass_ids, Array, desc: N_('IDs of associated Puppetclasses')
|
25
|
+
param :config_group_ids, Array, desc: N_('IDs of associated ConfigGroups')
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module ForemanPuppet
|
2
|
-
module
|
3
|
-
module
|
2
|
+
module Extensions
|
3
|
+
module ApiSmartProxiesController
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
+
NewEnvironment = Struct.new('Environment', :name)
|
7
|
+
|
6
8
|
included do
|
7
9
|
before_action :find_required_puppet_proxy, only: [:import_puppetclasses]
|
8
10
|
before_action :find_environment_id, only: [:import_puppetclasses]
|
@@ -70,17 +72,24 @@ module ForemanPuppet
|
|
70
72
|
@changed['updated'].keys + @changed['ignored'].keys).uniq.sort
|
71
73
|
|
72
74
|
@environments = environment_names.map do |name|
|
73
|
-
|
75
|
+
NewEnvironment.new(name)
|
74
76
|
end
|
75
77
|
|
76
78
|
unless @environments.any?
|
77
|
-
|
79
|
+
# check if environment id/name was valid at all
|
80
|
+
if @env_id && \
|
81
|
+
Environment.authorized(:view_environments).where(name: @env_id).or(Environment.authorized(:view_environments).where(id: @env_id)).empty?
|
82
|
+
render_message(_('The requested environment cannot be found.'))
|
83
|
+
else
|
84
|
+
render_message(_('No changes to your environments detected'))
|
85
|
+
end
|
78
86
|
return false
|
79
87
|
end
|
80
88
|
|
81
89
|
@environments.any?
|
82
90
|
end
|
83
91
|
|
92
|
+
# rubocop:disable Metrics/MethodLength
|
84
93
|
def import_changed_proxy_environments
|
85
94
|
opts = { url: @smart_proxy.url }
|
86
95
|
opts[:env] = if @environment.present?
|
@@ -92,7 +101,8 @@ module ForemanPuppet
|
|
92
101
|
changed = @importer.changes
|
93
102
|
|
94
103
|
# check if environemnt id passed in URL is name of NEW environment in puppetmaster that doesn't exist in db
|
95
|
-
|
104
|
+
@environment ||= NewEnvironment.new(@env_id) if changed['new'].key?(@env_id)
|
105
|
+
if @environment
|
96
106
|
# only return :keys equal to @environment in @changed hash
|
97
107
|
%w[new obsolete updated ignored].each do |kind|
|
98
108
|
changed[kind].slice!(@environment.name) unless changed[kind].empty?
|
@@ -109,6 +119,7 @@ module ForemanPuppet
|
|
109
119
|
render_message(msg, status: :internal_server_error)
|
110
120
|
nil
|
111
121
|
end
|
122
|
+
# rubocop:enable Metrics/MethodLength
|
112
123
|
|
113
124
|
def find_required_puppet_proxy
|
114
125
|
id = params.key?('smart_proxy_id') ? params['smart_proxy_id'] : params['id']
|
data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb
CHANGED
@@ -4,7 +4,29 @@ module ForemanPuppet
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
if
|
7
|
+
if Gem::Dependency.new('', '>= 3.1').match?('', SETTINGS[:version].notag)
|
8
|
+
index_desc = Apipie.get_method_description(self, :index)
|
9
|
+
index_desc.apis << Apipie::MethodDescription::Api.new(:GET, '/environments/:environment_id/template_combinations', N_('List template combination'), {})
|
10
|
+
|
11
|
+
create_desc = Apipie.get_method_description(self, :create)
|
12
|
+
create_desc.apis << Apipie::MethodDescription::Api.new(:POST, '/environments/:environment_id/template_combinations', N_('Add a template combination'), {})
|
13
|
+
|
14
|
+
show_desc = Apipie.get_method_description(self, :show)
|
15
|
+
show_desc.apis << Apipie::MethodDescription::Api.new(:GET, '/environments/:environment_id/template_combinations/:id', N_('Show template combination'), {})
|
16
|
+
|
17
|
+
update_desc = Apipie.get_method_description(self, :update)
|
18
|
+
update_desc.apis << Apipie::MethodDescription::Api.new(:PUT, '/environments/:environment_id/template_combinations/:id', N_('Update template combination'), {})
|
19
|
+
|
20
|
+
apipie_update_methods(%i[index create show update]) do
|
21
|
+
param :environment_id, String, desc: N_('ID of Puppet environment')
|
22
|
+
end
|
23
|
+
|
24
|
+
apipie_update_methods(%i[create update]) do
|
25
|
+
param :template_combination, Hash do
|
26
|
+
param :environment_id, :number, allow_nil: true, desc: N_('environment id')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
elsif ForemanPuppet.extracted_from_core?
|
8
30
|
apipie_update_methods(%i[index create show update]) do
|
9
31
|
param :environment_id, nil, desc: N_('ID of environment')
|
10
32
|
end
|
@@ -6,25 +6,23 @@ module ForemanPuppet
|
|
6
6
|
included do
|
7
7
|
prepend PatchMethods
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
method_desc.apis << Apipie::MethodDescription::Api.new(:GET, '/environments/:environment_id/hosts', N_('List hosts per environment'), {})
|
9
|
+
method_desc = Apipie.get_method_description(self, :index)
|
10
|
+
method_desc.apis << Apipie::MethodDescription::Api.new(:GET, '/environments/:environment_id/hosts', N_('List hosts per environment'), {})
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
apipie_update_methods([:index]) do
|
13
|
+
param :environment_id, String, desc: N_('ID of puppet environment')
|
14
|
+
end
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
apipie_update_methods(%i[create update]) do
|
17
|
+
param :host, Hash do
|
18
|
+
param :environment_id, String, desc: N_('Deprecated in favor of host/puppet_attributes/environment_id')
|
19
|
+
param :puppetclass_ids, Array, desc: N_('Deprecated in favor of host/puppet_attributes/puppetclass_ids')
|
20
|
+
param :config_group_ids, Array, desc: N_('Deprecated in favor of host/puppet_attributes/config_group_ids')
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
22
|
+
param :puppet_attributes, Hash do
|
23
|
+
param :environment_id, String, desc: N_('ID of associated puppet Environment')
|
24
|
+
param :puppetclass_ids, Array, desc: N_('IDs of associated Puppetclasses')
|
25
|
+
param :config_group_ids, Array, desc: N_('IDs of associated ConfigGroups')
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -39,7 +37,7 @@ module ForemanPuppet
|
|
39
37
|
|
40
38
|
def allowed_nested_id
|
41
39
|
ids = super
|
42
|
-
ids << 'environment_id'
|
40
|
+
ids << 'environment_id'
|
43
41
|
ids.uniq
|
44
42
|
end
|
45
43
|
end
|
@@ -31,7 +31,6 @@ module ForemanPuppet
|
|
31
31
|
helper ForemanPuppet::PuppetclassLookupKeysHelper
|
32
32
|
end
|
33
33
|
|
34
|
-
# TODO: unless ForemanPuppet.extracted_from_core?
|
35
34
|
def select_multiple_puppet_proxy_hosts_path(*args)
|
36
35
|
foreman_puppet.select_multiple_puppet_proxy_hosts_path(*args)
|
37
36
|
end
|
@@ -44,14 +44,8 @@ module ForemanPuppet
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def process_deprecated_hostgroup_environment_params!(params, top_level_hash = 'hostgroup')
|
47
|
-
env_id =
|
48
|
-
|
49
|
-
env_id = params.delete(:environment_id)
|
50
|
-
env_name = params.delete(:environment_name)
|
51
|
-
else
|
52
|
-
env_id = params[:environment_id]
|
53
|
-
env_name = params[:environment_name]
|
54
|
-
end
|
47
|
+
env_id = params.delete(:environment_id)
|
48
|
+
env_name = params.delete(:environment_name)
|
55
49
|
|
56
50
|
return unless env_id || env_name
|
57
51
|
::Foreman::Deprecation.api_deprecation_warning("param #{top_level_hash}[environment_*] has been deprecated in favor of #{top_level_hash}[puppet_attributes][environment_*]")
|
@@ -20,7 +20,7 @@ module ForemanPuppet
|
|
20
20
|
|
21
21
|
def create
|
22
22
|
@hostgroup_class = HostgroupClass.create!(hostgroup_puppet_facet_id: @hostgroup.puppet.id, puppetclass_id: params[:puppetclass_id].to_i)
|
23
|
-
render json: { hostgroup_id: @
|
23
|
+
render json: { hostgroup_id: @hostgroup.puppet.hostgroup_id, puppetclass_id: @hostgroup_class.puppetclass_id }
|
24
24
|
end
|
25
25
|
|
26
26
|
api :DELETE, '/hostgroups/:hostgroup_id/puppetclass_ids/:id/', N_('Remove a Puppet class from host group')
|
@@ -14,7 +14,7 @@ module ForemanPuppet
|
|
14
14
|
|
15
15
|
helper ForemanPuppet::PuppetclassLookupKeysHelper
|
16
16
|
|
17
|
-
# TODO:
|
17
|
+
# TODO: filter for facets needs improving
|
18
18
|
def host_params(top_level_hash = controller_name.singularize)
|
19
19
|
filter = self.class.host_params_filter
|
20
20
|
filter.permit(puppet_attributes: {})
|
@@ -10,7 +10,7 @@ module ForemanPuppet
|
|
10
10
|
|
11
11
|
def environments_title_actions
|
12
12
|
title_actions import_proxy_select(hash_for_import_environments_environments_path.merge(engine: foreman_puppet)),
|
13
|
-
button_group(new_link(_('Create Puppet Environment'), engine: foreman_puppet)),
|
13
|
+
button_group(new_link(_('Create Puppet Environment'), { engine: foreman_puppet }, id: 'new_environment')),
|
14
14
|
button_group(help_button)
|
15
15
|
end
|
16
16
|
end
|
@@ -1,10 +1,5 @@
|
|
1
1
|
module ForemanPuppet
|
2
2
|
module HostsAndHostgroupsHelper
|
3
|
-
# TODO: remove me - prevents the puppetclass tab duplication
|
4
|
-
# unless ForemanPuppet.extracted_from_core?
|
5
|
-
def puppetclasses_tab(puppetclasses_receiver)
|
6
|
-
end
|
7
|
-
|
8
3
|
def environment_inherited_by_default?(host)
|
9
4
|
return false unless host.hostgroup && host.hostgroup_id_was.nil?
|
10
5
|
return false if params[:action] == 'clone'
|
@@ -3,20 +3,16 @@ module ForemanPuppet
|
|
3
3
|
UI.register_host_description do
|
4
4
|
multiple_actions_provider :puppet_host_multiple_actions
|
5
5
|
# otherwise registered twice
|
6
|
-
overview_buttons_provider :puppet_host_overview_buttons
|
7
|
-
overview_fields_provider :puppet_host_overview_fields
|
6
|
+
overview_buttons_provider :puppet_host_overview_buttons
|
7
|
+
overview_fields_provider :puppet_host_overview_fields
|
8
8
|
end
|
9
9
|
|
10
10
|
def puppet_host_multiple_actions
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
actions << { action: [_('Change Puppet Master'), foreman_puppet.select_multiple_puppet_proxy_hosts_path], priority: 1050 }
|
15
|
-
end
|
16
|
-
actions
|
17
|
-
else
|
18
|
-
[]
|
11
|
+
actions = [{ action: [_('Change Environment'), foreman_puppet.select_multiple_environment_hosts_path], priority: 200 }]
|
12
|
+
if authorized_for(controller: :hosts, action: :edit) && SmartProxy.unscoped.authorized.with_features('Puppet').exists?
|
13
|
+
actions << { action: [_('Change Puppet Master'), foreman_puppet.select_multiple_puppet_proxy_hosts_path], priority: 1050 }
|
19
14
|
end
|
15
|
+
actions
|
20
16
|
end
|
21
17
|
|
22
18
|
def puppet_host_overview_buttons(host)
|
@@ -3,20 +3,12 @@ module ForemanPuppet
|
|
3
3
|
module Host
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
include ForemanPuppet::Extensions::HostCommon
|
6
|
+
include ForemanPuppet::Extensions::HostCommon
|
7
7
|
|
8
8
|
included do
|
9
9
|
prepend PrependedMethods
|
10
10
|
|
11
|
-
|
12
|
-
has_one :environment, through: :puppet, class_name: 'ForemanPuppet::Environment'
|
13
|
-
else
|
14
|
-
env_assoc = reflect_on_association(:environment)
|
15
|
-
env_assoc&.instance_variable_set(:@class_name, 'ForemanPuppet::Environment')
|
16
|
-
|
17
|
-
host_classes_assoc = reflect_on_association(:host_classes)
|
18
|
-
host_classes_assoc&.instance_variable_set(:@class_name, 'ForemanPuppet::HostClass')
|
19
|
-
end
|
11
|
+
has_one :environment, through: :puppet, class_name: 'ForemanPuppet::Environment'
|
20
12
|
|
21
13
|
include_in_clone puppet: %i[config_groups host_config_groups host_classes]
|
22
14
|
|
@@ -70,12 +62,6 @@ module ForemanPuppet
|
|
70
62
|
end
|
71
63
|
|
72
64
|
module PrependedMethods
|
73
|
-
# TODO: we can drop this once extracted_from_core?
|
74
|
-
def validate_association_taxonomy(association_name)
|
75
|
-
return if association_name.to_sym == :environment
|
76
|
-
super
|
77
|
-
end
|
78
|
-
|
79
65
|
def provisioning_template(opts = {})
|
80
66
|
opts[:environment_id] ||= puppet&.environment_id
|
81
67
|
super(opts)
|
@@ -3,19 +3,14 @@ module ForemanPuppet
|
|
3
3
|
module Hostgroup
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
include ForemanPuppet::Extensions::HostCommon
|
6
|
+
include ForemanPuppet::Extensions::HostCommon
|
7
7
|
|
8
8
|
included do
|
9
9
|
class << self
|
10
10
|
prepend PatchedClassMethods
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
has_one :environment, through: :puppet, class_name: 'ForemanPuppet::Environment'
|
15
|
-
else
|
16
|
-
env_assoc = reflect_on_association(:environment)
|
17
|
-
env_assoc&.instance_variable_set(:@class_name, 'ForemanPuppet::Environment')
|
18
|
-
end
|
13
|
+
has_one :environment, through: :puppet, class_name: 'ForemanPuppet::Environment'
|
19
14
|
|
20
15
|
include_in_clone puppet: %i[host_config_groups config_groups hostgroup_classes]
|
21
16
|
|
@@ -4,21 +4,16 @@ module ForemanPuppet
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
8
|
-
|
9
|
-
before_destroy ActiveRecord::Base::EnsureNotUsedBy.new(:environments)
|
7
|
+
has_many :environments, through: :template_combinations
|
8
|
+
before_destroy EnsureNotUsedBy.new(:environments)
|
10
9
|
|
11
|
-
|
10
|
+
scoped_search relation: :environments, on: :name, rename: :environment, complete_value: true
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
prepend PrependedMethods
|
18
|
-
else
|
19
|
-
env_assoc = reflect_on_association(:environments)
|
20
|
-
env_assoc&.instance_variable_set(:@class_name, 'ForemanPuppet::Environment')
|
12
|
+
class << self
|
13
|
+
prepend PrependedClassMethods
|
21
14
|
end
|
15
|
+
|
16
|
+
prepend PrependedMethods
|
22
17
|
end
|
23
18
|
|
24
19
|
module PrependedClassMethods
|
@@ -4,19 +4,14 @@ module ForemanPuppet
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
|
8
|
-
belongs_to :environment, class_name: 'ForemanPuppet::Environment'
|
7
|
+
belongs_to :environment, class_name: 'ForemanPuppet::Environment'
|
9
8
|
|
10
|
-
|
9
|
+
validates :environment_id, uniqueness: { scope: %i[hostgroup_id provisioning_template_id] }
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
callback.filter.options[:scope] << :environment_id
|
16
|
-
else
|
17
|
-
env_assoc = reflect_on_association(:environment)
|
18
|
-
env_assoc&.instance_variable_set(:@class_name, 'ForemanPuppet::Environment')
|
11
|
+
callback = __callbacks[:validate].detect do |v|
|
12
|
+
v.filter.is_a?(ActiveRecord::Validations::UniquenessValidator) && v.filter.attributes.include?(:hostgroup_id)
|
19
13
|
end
|
14
|
+
callback.filter.options[:scope] << :environment_id
|
20
15
|
end
|
21
16
|
end
|
22
17
|
end
|
@@ -308,12 +308,6 @@ module ForemanPuppet
|
|
308
308
|
env.puppetclasses.destroy classes
|
309
309
|
# remove all old classes from hosts
|
310
310
|
HostClass.joins(host: :puppet).where(HostPuppetFacet.arel_table[:environment_id].eq(env.id)).where(puppetclass_id: classes).destroy_all
|
311
|
-
unless ForemanPuppet.extracted_from_core?
|
312
|
-
# rubocop:disable Rails/SkipsModelValidations
|
313
|
-
Host.where(environment_id: env).update_all(environment_id: nil)
|
314
|
-
Hostgroup.where(environment_id: env).update_all(environment_id: nil)
|
315
|
-
# rubocop:enable Rails/SkipsModelValidations
|
316
|
-
end
|
317
311
|
# we can't guaranty that the env would be removed as it might have hosts attached to it.
|
318
312
|
env.destroy if klasses.include? '_destroy_'
|
319
313
|
# remove all klasses that have no environment now
|
@@ -1,4 +1,8 @@
|
|
1
|
-
|
1
|
+
<%
|
2
|
+
li_id = "#{added ? 'selected_' : '' }config_group_#{config_group.id}"
|
3
|
+
li_class = "#{added ? 'selected_config_group' : 'config_group'} #{css_class}"
|
4
|
+
%>
|
5
|
+
<%= content_tag :li, id: li_id, class: li_class do %>
|
2
6
|
<%= hidden_field_tag("#{type}[config_group_ids][]", config_group.id) if added == 'manually' %>
|
3
7
|
<span>
|
4
8
|
<%= link_to(icon_text('plus', config_group.name), '#', :rel=>'twipsy', :class => 'config_group_name',
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<% content_for(:search_bar) { } %>
|
3
3
|
<% title _('Config Groups') %>
|
4
4
|
|
5
|
-
<% title_actions new_link(_('Create Config Group'), engine: foreman_puppet), help_button %>
|
5
|
+
<% title_actions new_link(_('Create Config Group'), { engine: foreman_puppet }, id: 'new_config_group'), help_button %>
|
6
6
|
|
7
7
|
<table class="<%= table_css_classes 'table-fixed' %>">
|
8
8
|
<thead>
|
data/config/api_routes.rb
CHANGED
@@ -2,14 +2,6 @@ ForemanPuppet::Engine.routes.draw do
|
|
2
2
|
namespace :api, defaults: { format: 'json' } do
|
3
3
|
scope '(:apiv)', module: :v2, defaults: { apiv: 'v2' }, apiv: /v1|v2/, constraints: ApiConstraints.new(version: 2, default: true) do
|
4
4
|
constraints(id: %r{[^/]+}) do
|
5
|
-
resources :puppet_smart_proxies, only: [] do
|
6
|
-
post :import_puppetclasses, on: :member, controller: 'environments'
|
7
|
-
|
8
|
-
resources :environments, only: [] do
|
9
|
-
post :import_puppetclasses, on: :member
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
5
|
resources :config_groups, except: %i[new edit]
|
14
6
|
|
15
7
|
resources :hosts, only: [] do
|
@@ -40,7 +32,7 @@ ForemanPuppet::Engine.routes.draw do
|
|
40
32
|
end
|
41
33
|
end
|
42
34
|
resources :hosts, only: %i[index show], controller: '/api/v2/hosts'
|
43
|
-
resources :template_combinations, only: %i[index], controller: '/api/v2/template_combinations'
|
35
|
+
resources :template_combinations, only: %i[index show create update], controller: '/api/v2/template_combinations'
|
44
36
|
end
|
45
37
|
|
46
38
|
resources :puppetclasses, except: %i[new edit] do
|
@@ -1,13 +1,81 @@
|
|
1
1
|
Foreman::Application.routes.prepend do
|
2
2
|
namespace :api, defaults: { format: 'json' } do
|
3
3
|
scope '(:apiv)', module: :v2, defaults: { apiv: 'v2' }, apiv: /v2/, constraints: ApiConstraints.new(version: 2, default: true) do
|
4
|
-
resources :
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
resources :smart_proxies, only: [] do
|
5
|
+
post :import_puppetclasses, on: :member
|
6
|
+
resources :environments, only: [] do
|
7
|
+
post :import_puppetclasses, on: :member, controller: '/api/v2/smart_proxies'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
8
11
|
resources :config_groups, controller: '/foreman_puppet/api/v2/config_groups', except: %i[new edit]
|
9
|
-
|
12
|
+
|
13
|
+
resources :hosts, only: [] do
|
14
|
+
resources :puppetclasses, controller: '/foreman_puppet/api/v2/puppetclasses', except: %i[new edit]
|
15
|
+
resources :smart_class_parameters, controller: '/foreman_puppet/api/v2/smart_class_parameters', except: %i[new edit create] do
|
16
|
+
resources :override_values, controller: '/foreman_puppet/api/v2/override_values', except: %i[new edit]
|
17
|
+
end
|
18
|
+
resources :host_classes, path: :puppetclass_ids, controller: '/foreman_puppet/api/v2/host_classes', only: %i[index create destroy]
|
19
|
+
end
|
20
|
+
|
21
|
+
resources :hostgroups, only: [] do
|
22
|
+
resources :puppetclasses, controller: '/foreman_puppet/api/v2/puppetclasses', except: %i[new edit]
|
23
|
+
resources :smart_class_parameters, controller: '/foreman_puppet/api/v2/smart_class_parameters', except: %i[new edit create] do
|
24
|
+
resources :override_values, controller: '/foreman_puppet/api/v2/override_values', except: %i[new edit]
|
25
|
+
end
|
26
|
+
resources :hostgroup_classes, path: :puppetclass_ids, controller: '/foreman_puppet/api/v2/hostgroup_classes', only: %i[index create destroy]
|
27
|
+
end
|
28
|
+
|
29
|
+
resources :environments, controller: '/foreman_puppet/api/v2/environments', except: %i[new edit] do
|
30
|
+
resources :locations, only: %i[index show]
|
31
|
+
resources :organizations, only: %i[index show]
|
32
|
+
resources :smart_proxies, only: [] do
|
33
|
+
post :import_puppetclasses, on: :member
|
34
|
+
end
|
35
|
+
resources :smart_class_parameters, controller: '/foreman_puppet/api/v2/smart_class_parameters', except: %i[new edit create] do
|
36
|
+
resources :override_values, controller: '/foreman_puppet/api/v2/override_values', except: %i[new edit]
|
37
|
+
end
|
38
|
+
resources :puppetclasses, controller: '/foreman_puppet/api/v2/puppetclasses', except: %i[new edit] do
|
39
|
+
resources :smart_class_parameters, controller: '/foreman_puppet/api/v2/smart_class_parameters', except: %i[new edit create] do
|
40
|
+
resources :override_values, controller: '/foreman_puppet/api/v2/override_values', except: %i[new edit destroy]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
resources :hosts, only: %i[index show]
|
44
|
+
resources :template_combinations, only: %i[index show create update]
|
45
|
+
end
|
46
|
+
|
47
|
+
resources :puppetclasses, controller: '/foreman_puppet/api/v2/puppetclasses', except: %i[new edit] do
|
48
|
+
resources :smart_class_parameters, controller: '/foreman_puppet/api/v2/smart_class_parameters', except: %i[new edit create] do
|
49
|
+
resources :override_values, controller: '/foreman_puppet/api/v2/override_values', except: %i[new edit]
|
50
|
+
end
|
51
|
+
resources :environments, controller: '/foreman_puppet/api/v2/environments', only: %i[index show] do
|
52
|
+
resources :smart_class_parameters, controller: '/foreman_puppet/api/v2/smart_class_parameters', except: %i[new edit create] do
|
53
|
+
resources :override_values, controller: '/foreman_puppet/api/v2/override_values', except: %i[new edit]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
resources :smart_class_parameters, controller: '/foreman_puppet/api/v2/smart_class_parameters', except: %i[new edit create destroy] do
|
59
|
+
resources :override_values, controller: '/foreman_puppet/api/v2/override_values', except: %i[new edit]
|
60
|
+
end
|
61
|
+
|
10
62
|
resources :override_values, controller: '/foreman_puppet/api/v2/override_values', except: %i[new edit]
|
63
|
+
|
64
|
+
resources :locations, only: [] do
|
65
|
+
resources :environments, controller: '/foreman_puppet/api/v2/environments', only: %i[index show]
|
66
|
+
|
67
|
+
resources :organizations, only: [] do
|
68
|
+
resources :environments, controller: '/foreman_puppet/api/v2/environments', only: %i[index show]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
resources :organizations, only: [] do
|
73
|
+
resources :environments, controller: '/foreman_puppet/api/v2/environments', only: %i[index show]
|
74
|
+
|
75
|
+
resources :locations, only: [] do
|
76
|
+
resources :environments, controller: '/foreman_puppet/api/v2/environments', only: %i[index show]
|
77
|
+
end
|
78
|
+
end
|
11
79
|
end
|
12
80
|
end
|
13
81
|
end
|
@@ -4,6 +4,6 @@ class AddEnvironmentToTemplateCombinations < ActiveRecord::Migration[4.2]
|
|
4
4
|
end
|
5
5
|
|
6
6
|
def down
|
7
|
-
remove_reference :template_combinations, :environment, foreign_key: true
|
7
|
+
remove_reference :template_combinations, :environment, foreign_key: true
|
8
8
|
end
|
9
9
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class MigrateEnvironmentToPuppetFacet < ActiveRecord::Migration[6.0]
|
2
2
|
def up
|
3
|
+
return true unless column_exists?(:hosts, :environment_id)
|
3
4
|
puppet_hostgroups = ::Hostgroup.unscoped.where.not(environment_id: nil).pluck(:id, :environment_id)
|
4
5
|
puppet_hostgroups.map! { |hg_id, env_id| { hostgroup_id: hg_id, environment_id: env_id } }
|
5
6
|
ForemanPuppet::HostgroupPuppetFacet.insert_all!(puppet_hostgroups) if puppet_hostgroups.any?
|
@@ -10,6 +11,7 @@ class MigrateEnvironmentToPuppetFacet < ActiveRecord::Migration[6.0]
|
|
10
11
|
end
|
11
12
|
|
12
13
|
def down
|
14
|
+
return true unless column_exists?(:hosts, :environment_id)
|
13
15
|
hostgroup_facet_ids = ForemanPuppet::HostgroupPuppetFacet.all.pluck(:hostgroup_id, :environment_id)
|
14
16
|
hostgroup_facet_ids.each do |hostgroup_id, env_id|
|
15
17
|
::Hostgroup.unscoped.where(id: hostgroup_id).update_all(environment_id: env_id)
|