foreman_puppet 1.0.4 → 1.0.5
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 +4 -4
- data/app/controllers/concerns/foreman_puppet/extensions/hostgroups_controller_extensions.rb +3 -1
- data/app/models/foreman_puppet/host_puppet_facet.rb +1 -1
- data/app/models/foreman_puppet/hostgroup_puppet_facet.rb +2 -0
- data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +36 -20
- data/db/migrate/20211112130803_cleanup_environment_from_core_tables.foreman_puppet.rb +10 -0
- data/lib/foreman_puppet/version.rb +1 -1
- data/locale/cs_CZ/foreman_puppet.edit.po +1085 -0
- data/locale/cs_CZ/foreman_puppet.po.time_stamp +0 -0
- data/locale/en/foreman_puppet.edit.po +317 -162
- data/test/helpers/foreman_puppet/hosts_and_hostgroups_helper_test.rb +70 -31
- data/test/models/foreman_puppet/host_puppet_facet_test.rb +7 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f8a5c7b68f8d77f54787c4c9de924bc02f27d7a0f957fc6539b5b4aa6c64b49
|
4
|
+
data.tar.gz: 6cd563d9cc2f56c22186bbbb0fb9d3c9679c8718e965d7fd952bbed3efacf222
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a09cf7ff50545983f0e472b3c03f0708087dddf8d2136dc32978f49a1fd76ba7ca4c716db6e6b3add3055279745754b2d2eddf2cd1630a91e75187ba9683c1e
|
7
|
+
data.tar.gz: 5c4bb18d77784e2a9c43c7f102adc9df6469b739525fee007d1c89bf635713e1dd051140489101ebeb9d66298100195f56571fa5fb55a1a179c8381cac56a65b
|
@@ -23,7 +23,9 @@ module ForemanPuppet
|
|
23
23
|
module Actions
|
24
24
|
def nest
|
25
25
|
super
|
26
|
-
|
26
|
+
return unless @parent.puppet
|
27
|
+
puppet = @hostgroup.puppet || @hostgroup.build_puppet
|
28
|
+
puppet.puppetclasses = @parent.puppet.puppetclasses
|
27
29
|
end
|
28
30
|
|
29
31
|
def environment_selected
|
@@ -48,6 +48,8 @@ module ForemanPuppet
|
|
48
48
|
Hostgroup.sort_by_ancestry(hostgroup.ancestors.joins(:puppet).where(HostgroupPuppetFacet.arel_table[attr.to_sym].not_eq(nil))).last&.puppet.try(attr)
|
49
49
|
end
|
50
50
|
|
51
|
+
delegate :parent_id, to: :hostgroup
|
52
|
+
|
51
53
|
# and helpers
|
52
54
|
def parent_facet_id
|
53
55
|
parent_facet&.id
|
@@ -13,26 +13,8 @@ class MigrateHostTypeInHostConfigGroups < ActiveRecord::Migration[6.0]
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def up
|
16
|
-
|
17
|
-
|
18
|
-
host_facet_id = ForemanPuppet::HostPuppetFacet.where(host_id: host_id).pick(:id)
|
19
|
-
host_groups = FakeHostConfigGroup.for_host.where(host_id: host_id)
|
20
|
-
if host_facet_id
|
21
|
-
host_groups.update_all(host_type: 'ForemanPuppet::HostPuppetFacet', host_id: host_facet_id)
|
22
|
-
else
|
23
|
-
deleted_groups = FakeConfigGroup.where(id: host_groups.pluck(:config_group_id)).pluck(:name)
|
24
|
-
say "deleting groups #{deleted_groups.join(', ')} from Host (id=#{host_id}) because it has no environment"
|
25
|
-
host_groups.delete_all
|
26
|
-
end
|
27
|
-
end
|
28
|
-
hostgroup_config_group_ids = FakeHostConfigGroup.for_hostgroup.pluck(:host_id).uniq
|
29
|
-
hostgroup_config_group_ids.each do |hostgroup_id|
|
30
|
-
hostgroup_facet_id = ForemanPuppet::HostgroupPuppetFacet.where(hostgroup_id: hostgroup_id).pick(:id)
|
31
|
-
hostgroup_facet_id ||= ForemanPuppet::HostgroupPuppetFacet.create!(hostgroup: Hostgroup.unscoped.find(hostgroup_id)).id
|
32
|
-
FakeHostConfigGroup.for_hostgroup
|
33
|
-
.where(host_id: hostgroup_id)
|
34
|
-
.update_all(host_type: 'ForemanPuppet::HostgroupPuppetFacet', host_id: hostgroup_facet_id)
|
35
|
-
end
|
16
|
+
migrate_host_data_to_facets
|
17
|
+
migrate_hostgroup_data_to_facets
|
36
18
|
end
|
37
19
|
|
38
20
|
def down
|
@@ -51,4 +33,38 @@ class MigrateHostTypeInHostConfigGroups < ActiveRecord::Migration[6.0]
|
|
51
33
|
.update_all(host_type: 'Hostgroup', host_id: hostgroup_facet_ids[hostgroup_facet_id])
|
52
34
|
end
|
53
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def migrate_host_data_to_facets
|
40
|
+
host_config_group_ids = FakeHostConfigGroup.for_host.pluck(:host_id).uniq
|
41
|
+
host_config_group_ids.each do |host_id|
|
42
|
+
host_facet_id = ForemanPuppet::HostPuppetFacet.where(host_id: host_id).pick(:id)
|
43
|
+
host_groups = FakeHostConfigGroup.for_host.where(host_id: host_id)
|
44
|
+
if host_facet_id
|
45
|
+
host_groups.update_all(host_type: 'ForemanPuppet::HostPuppetFacet', host_id: host_facet_id)
|
46
|
+
else
|
47
|
+
deleted_groups = FakeConfigGroup.where(id: host_groups.pluck(:config_group_id)).pluck(:name)
|
48
|
+
say "Deleting Config groups #{deleted_groups.join(', ')} from Host (id=#{host_id}) because the Host doesn't exist or has no environment"
|
49
|
+
host_groups.delete_all
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def migrate_hostgroup_data_to_facets
|
55
|
+
hostgroup_config_group_ids = FakeHostConfigGroup.for_hostgroup.pluck(:host_id).uniq
|
56
|
+
hostgroup_config_group_ids.each do |hostgroup_id|
|
57
|
+
hostgroup = Hostgroup.unscoped.find_by(id: hostgroup_id)
|
58
|
+
hostgroup_groups = FakeHostConfigGroup.for_hostgroup.where(host_id: hostgroup_id)
|
59
|
+
if hostgroup
|
60
|
+
hostgroup_facet_id = ForemanPuppet::HostgroupPuppetFacet.where(hostgroup_id: hostgroup_id).pick(:id)
|
61
|
+
hostgroup_facet_id ||= ForemanPuppet::HostgroupPuppetFacet.create!(hostgroup: hostgroup).id
|
62
|
+
hostgroup_groups.update_all(host_type: 'ForemanPuppet::HostgroupPuppetFacet', host_id: hostgroup_facet_id)
|
63
|
+
else
|
64
|
+
deleted_groups = FakeConfigGroup.where(id: hostgroup_groups.pluck(:config_group_id)).pluck(:name)
|
65
|
+
say "Deleting Config groups #{deleted_groups.join(', ')} from Hostgroup (id=#{hostgroup_id}) because Hostgroup doesn't exist"
|
66
|
+
hostgroup_groups.delete_all
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
54
70
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class CleanupEnvironmentFromCoreTables < ActiveRecord::Migration[6.0]
|
2
|
+
def up
|
3
|
+
::Hostgroup.update_all(environment_id: nil) if column_exists?(:hostgroups, :environment_id)
|
4
|
+
Host::Managed.update_all(environment_id: nil) if column_exists?(:hosts, :environment_id)
|
5
|
+
end
|
6
|
+
|
7
|
+
def down
|
8
|
+
# nothing to do
|
9
|
+
end
|
10
|
+
end
|