foreman_puppet 0.1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/foreman_puppet/extensions/api_base_controller.rb +28 -0
- data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb +1 -1
- data/app/controllers/foreman_puppet/api/v2/config_groups_controller.rb +5 -1
- data/app/controllers/foreman_puppet/api/v2/environments_controller.rb +1 -2
- data/app/controllers/foreman_puppet/api/v2/host_classes_controller.rb +5 -1
- data/app/controllers/foreman_puppet/api/v2/hostgroup_classes_controller.rb +5 -1
- data/app/controllers/foreman_puppet/api/v2/override_values_controller.rb +1 -2
- data/app/controllers/foreman_puppet/api/v2/{base_controller.rb → puppet_base_controller.rb} +3 -4
- data/app/controllers/foreman_puppet/api/v2/{lookups_common_controller.rb → puppet_lookups_common_controller.rb} +6 -2
- data/app/controllers/foreman_puppet/api/v2/puppetclasses_controller.rb +5 -1
- data/app/controllers/foreman_puppet/api/v2/smart_class_parameters_controller.rb +1 -2
- data/app/controllers/foreman_puppet/puppetclasses_controller.rb +9 -2
- data/app/graphgl/concerns/foreman_puppet/mutations/hosts/create_extensions.rb +29 -0
- data/app/graphgl/concerns/foreman_puppet/types/host_extensions.rb +13 -0
- data/app/graphgl/concerns/foreman_puppet/types/hostgroup_extensions.rb +13 -0
- data/app/graphgl/concerns/foreman_puppet/types/interface_attributes_input_extensions.rb +9 -0
- data/app/graphgl/concerns/foreman_puppet/types/location_extensions.rb +14 -0
- data/app/graphgl/concerns/foreman_puppet/types/organization_extensions.rb +14 -0
- data/app/graphgl/foreman_puppet/types/environment.rb +20 -0
- data/app/graphgl/foreman_puppet/types/puppetclass.rb +20 -0
- data/app/helpers/foreman_puppet/puppetclasses_and_environments_helper.rb +1 -1
- data/app/helpers/foreman_puppet/puppetclasses_helper.rb +2 -2
- data/app/models/concerns/foreman_puppet/extensions/host.rb +9 -5
- data/app/models/concerns/foreman_puppet/extensions/host_common.rb +17 -0
- data/app/models/concerns/foreman_puppet/extensions/hostgroup.rb +8 -2
- data/app/models/concerns/foreman_puppet/extensions/operatingsystem.rb +1 -1
- data/app/models/concerns/foreman_puppet/extensions/provisioning_template.rb +17 -11
- data/app/models/concerns/foreman_puppet/extensions/taxonomy.rb +1 -1
- data/app/models/foreman_puppet/environment.rb +2 -0
- data/app/models/foreman_puppet/host_puppet_facet.rb +2 -2
- data/app/models/foreman_puppet/hostgroup_puppet_facet.rb +1 -1
- data/app/models/{concerns/foreman_puppet/host_common.rb → foreman_puppet/puppet_facet_common.rb} +1 -1
- data/app/models/foreman_puppet/puppetclass.rb +2 -0
- data/app/{views/api/v2/template_combinations/base.json.erb → prepend_views/api/v2/template_combinations/base.json.rabl} +0 -0
- data/app/services/foreman_puppet/host_info_providers/config_groups_info.rb +2 -0
- data/app/services/foreman_puppet/puppet_class_importer.rb +3 -4
- data/app/views/foreman_puppet/config_groups/index.html.erb +2 -2
- data/app/views/foreman_puppet/config_groups/welcome.html.erb +12 -11
- data/app/views/foreman_puppet/environments/welcome.html.erb +3 -15
- data/app/views/foreman_puppet/puppetclass_lookup_keys/welcome.html.erb +10 -8
- data/app/views/smart_proxies/plugins/_puppet_ca.html.erb +44 -0
- data/config/initializers/api_reroute.rb +13 -0
- data/db/migrate/20200803113903_migrate_host_type_in_host_config_groups.foreman_puppet.rb +35 -10
- data/db/migrate/20201125113903_migrate_puppetclasses_to_facets.foreman_puppet.rb +13 -1
- data/lib/foreman_puppet/engine.rb +61 -17
- data/lib/foreman_puppet/register.rb +6 -2
- data/lib/foreman_puppet/version.rb +1 -1
- data/lib/foreman_puppet.rb +1 -1
- data/locale/en/foreman_puppet.edit.po +927 -0
- data/locale/en/foreman_puppet.po.time_stamp +0 -0
- data/locale/en/foreman_puppet.pox +0 -0
- data/locale/messages.mo +0 -0
- data/test/controllers/foreman_puppet/api/v2/config_groups_controller_test.rb +7 -3
- data/test/controllers/foreman_puppet/api/v2/environments_controller_test.rb +17 -15
- data/test/controllers/foreman_puppet/api/v2/hosts_controller_test.rb +2 -1
- data/test/controllers/foreman_puppet/api/v2/lookups_common_controller_test.rb +1 -1
- data/test/controllers/foreman_puppet/api/v2/puppetclasses_controller_test.rb +3 -0
- data/test/controllers/foreman_puppet/api/v2/smart_class_parameters_controller_test.rb +7 -1
- data/test/controllers/foreman_puppet/api/v2/template_combinations_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/config_groups_controller_test.rb +7 -3
- data/test/controllers/foreman_puppet/environments_controller_test.rb +1 -1
- data/test/controllers/foreman_puppet/puppetclass_lookup_keys_controller_test.rb +2 -2
- data/test/controllers/foreman_puppet/puppetclasses_controller_test.rb +5 -6
- data/test/factories/host_puppet_enhancements.rb +6 -6
- data/test/graphql/mutations/hosts/create_mutation_test.rb +87 -0
- data/test/graphql/queries/environment_query_test.rb +54 -0
- data/test/graphql/queries/environments_query_test.rb +43 -0
- data/test/{qraphql → graphql}/queries/host_puppet_query_test.rb +3 -8
- data/test/{qraphql → graphql}/queries/hostgroup_puppet_query_test.rb +1 -6
- data/test/graphql/queries/location_query_test.rb +52 -0
- data/test/graphql/queries/organization_query_test.rb +52 -0
- data/test/graphql/queries/puppetclass_query_test.rb +68 -0
- data/test/graphql/queries/puppetclasses_query_test.rb +43 -0
- data/test/integration/foreman_puppet/environment_js_test.rb +4 -1
- data/test/integration/foreman_puppet/host_js_test.rb +1 -1
- data/test/integration/foreman_puppet/puppetclass_js_test.rb +1 -0
- data/test/models/foreman_puppet/config_group_class_test.rb +3 -1
- data/test/models/foreman_puppet/environment_test.rb +2 -0
- data/test/models/foreman_puppet/host_test.rb +3 -2
- data/test/models/foreman_puppet/hostgroup_puppet_facet_test.rb +2 -3
- data/test/models/foreman_puppet/provisioning_template_test.rb +30 -23
- data/test/models/foreman_puppet/smart_proxy_test.rb +1 -1
- data/test/models/foreman_puppet/user_test.rb +13 -5
- data/test/services/foreman_puppet/host_info_providers/config_groups_info_test.rb +35 -0
- data/test/services/foreman_puppet/host_info_providers/puppet_info_test.rb +0 -36
- data/test/unit/foreman_puppet/puppet_class_importer_test.rb +3 -1
- data/webpack/index.js +3 -4
- data/webpack/src/Components/Environments/Welcome.js +37 -0
- metadata +81 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c94283a315fba5f8c4f0d7cca627639f595cbbeb09a6806ab363762ba1b0334
|
4
|
+
data.tar.gz: 6a503f11d1be7297370f7d34557024e1a9186f579710ca73a902acb81b766ef8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be25708b1c38b99dfa4b2bee8d2e1f7da8f3f546a88a4a54b666673de28b08770b274e6cb098fa4eead33dc6770a93c4c1bba3e38dc45721ecbe148dbc9671b2
|
7
|
+
data.tar.gz: fa689ed7f12f34fc33fa7a0f9a7ca658ede1ca947cd4d37c77c10a015b5f933fd0d1116d0574bb308e743d4d9739990396005b5ff8ba9109d89df052f3332394
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
module Extensions
|
3
|
+
module ApiBaseController
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
prepend PatchMethods
|
8
|
+
|
9
|
+
before_action :prepare_views
|
10
|
+
end
|
11
|
+
|
12
|
+
def prepare_views
|
13
|
+
prepend_view_path ForemanPuppet::Engine.root.join('app', 'prepend_views')
|
14
|
+
end
|
15
|
+
|
16
|
+
module PatchMethods
|
17
|
+
def resource_name(resource = controller_name)
|
18
|
+
case resource
|
19
|
+
when 'environment'
|
20
|
+
'foreman_puppet/environment'
|
21
|
+
else
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/app/controllers/concerns/foreman_puppet/extensions/api_template_combinations_controller.rb
CHANGED
@@ -6,7 +6,7 @@ module ForemanPuppet
|
|
6
6
|
included do
|
7
7
|
if ForemanPuppet.extracted_from_core?
|
8
8
|
apipie_update_methods(%i[index create show update]) do
|
9
|
-
param :environment_id,
|
9
|
+
param :environment_id, nil, desc: N_('ID of environment')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module ForemanPuppet
|
2
2
|
module Api
|
3
3
|
module V2
|
4
|
-
class ConfigGroupsController <
|
4
|
+
class ConfigGroupsController < ::ForemanPuppet::Api::V2::PuppetBaseController
|
5
5
|
include ForemanPuppet::Parameters::ConfigGroup
|
6
6
|
|
7
|
+
resource_description do
|
8
|
+
api_base_url '/foreman_puppet/api'
|
9
|
+
end
|
10
|
+
|
7
11
|
wrap_parameters ConfigGroup, include: config_group_params_filter.accessible_attributes(parameter_filter_context)
|
8
12
|
|
9
13
|
before_action :find_resource, only: %i[show update destroy]
|
@@ -1,12 +1,11 @@
|
|
1
1
|
module ForemanPuppet
|
2
2
|
module Api
|
3
3
|
module V2
|
4
|
-
class EnvironmentsController <
|
4
|
+
class EnvironmentsController < ::ForemanPuppet::Api::V2::PuppetBaseController
|
5
5
|
include ForemanPuppet::Api::ImportPuppetclassesCommonController
|
6
6
|
include ForemanPuppet::Parameters::Environment
|
7
7
|
|
8
8
|
resource_description do
|
9
|
-
api_version '2'
|
10
9
|
api_base_url '/foreman_puppet/api'
|
11
10
|
end
|
12
11
|
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module ForemanPuppet
|
2
2
|
module Api
|
3
3
|
module V2
|
4
|
-
class HostClassesController < V2::
|
4
|
+
class HostClassesController < ::ForemanPuppet::Api::V2::PuppetBaseController
|
5
|
+
resource_description do
|
6
|
+
api_base_url '/foreman_puppet/api'
|
7
|
+
end
|
8
|
+
|
5
9
|
before_action :find_host, only: %i[index create destroy]
|
6
10
|
before_action :find_puppetclass, only: %i[create destroy]
|
7
11
|
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module ForemanPuppet
|
2
2
|
module Api
|
3
3
|
module V2
|
4
|
-
class HostgroupClassesController < V2::
|
4
|
+
class HostgroupClassesController < ::ForemanPuppet::Api::V2::PuppetBaseController
|
5
|
+
resource_description do
|
6
|
+
api_base_url '/foreman_puppet/api'
|
7
|
+
end
|
8
|
+
|
5
9
|
before_action :find_hostgroup, only: %i[index create destroy]
|
6
10
|
|
7
11
|
api :GET, '/hostgroups/:hostgroup_id/puppetclass_ids/', N_('List all Puppet class IDs for host group')
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module ForemanPuppet
|
2
2
|
module Api
|
3
3
|
module V2
|
4
|
-
class OverrideValuesController <
|
4
|
+
class OverrideValuesController < ::ForemanPuppet::Api::V2::PuppetLookupsCommonController
|
5
5
|
include Foreman::Controller::Parameters::LookupValue
|
6
6
|
|
7
7
|
resource_description do
|
8
|
-
api_version '2'
|
9
8
|
api_base_url '/foreman_puppet/api'
|
10
9
|
end
|
11
10
|
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module ForemanPuppet
|
2
2
|
module Api
|
3
3
|
module V2
|
4
|
-
class
|
4
|
+
class PuppetBaseController < ::Api::V2::BaseController
|
5
5
|
resource_description do
|
6
|
-
api_version '
|
7
|
-
api_base_url '/foreman_puppet/api'
|
6
|
+
api_version 'v2'
|
8
7
|
end
|
9
8
|
|
10
9
|
before_action :show_deprecation_for_core_routes
|
@@ -12,7 +11,7 @@ module ForemanPuppet
|
|
12
11
|
protected
|
13
12
|
|
14
13
|
def show_deprecation_for_core_routes
|
15
|
-
return if request.path.starts_with?('/foreman_puppet')
|
14
|
+
return if request.path.starts_with?('/foreman_puppet') || request.path.starts_with?('/api/smart_proxies')
|
16
15
|
Foreman::Deprecation.api_deprecation_warning(
|
17
16
|
format(
|
18
17
|
'/api/v2/%{controller} API endpoints are deprecated, please use /foreman_puppet/api/v2/%{controller} instead',
|
@@ -1,7 +1,11 @@
|
|
1
1
|
module ForemanPuppet
|
2
2
|
module Api
|
3
3
|
module V2
|
4
|
-
class
|
4
|
+
class PuppetLookupsCommonController < ::Api::V2::BaseController
|
5
|
+
resource_description do
|
6
|
+
api_version 'v2'
|
7
|
+
end
|
8
|
+
|
5
9
|
before_action :find_environment, if: :environment_id?
|
6
10
|
before_action :find_puppetclass, if: :puppetclass_id?
|
7
11
|
before_action :find_host, if: :host_id?
|
@@ -45,7 +49,7 @@ module ForemanPuppet
|
|
45
49
|
|
46
50
|
def find_smart_class_parameter
|
47
51
|
id = params.key?('smart_class_parameter_id') ? params['smart_class_parameter_id'] : params['id']
|
48
|
-
@smart_class_parameter = PuppetclassLookupKey.authorized(:view_external_parameters).smart_class_parameters.find_by(id: id.to_i) if id.to_i
|
52
|
+
@smart_class_parameter = PuppetclassLookupKey.authorized(:view_external_parameters).smart_class_parameters.find_by(id: id.to_i) if id.to_i.positive?
|
49
53
|
@smart_class_parameter ||= begin
|
50
54
|
puppet_cond = { 'environment_classes.puppetclass_id' => @puppetclass.id } if @puppetclass
|
51
55
|
env_cond = { 'environment_classes.environment_id' => @environment.id } if @environment
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module ForemanPuppet
|
2
2
|
module Api
|
3
3
|
module V2
|
4
|
-
class PuppetclassesController <
|
4
|
+
class PuppetclassesController < ::ForemanPuppet::Api::V2::PuppetBaseController
|
5
5
|
include ForemanPuppet::Parameters::Puppetclass
|
6
6
|
|
7
|
+
resource_description do
|
8
|
+
api_base_url '/foreman_puppet/api'
|
9
|
+
end
|
10
|
+
|
7
11
|
before_action :find_optional_nested_object
|
8
12
|
before_action :find_resource, only: %w[show update destroy]
|
9
13
|
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module ForemanPuppet
|
2
2
|
module Api
|
3
3
|
module V2
|
4
|
-
class SmartClassParametersController < ForemanPuppet::Api::V2::
|
4
|
+
class SmartClassParametersController < ::ForemanPuppet::Api::V2::PuppetLookupsCommonController
|
5
5
|
include ForemanPuppet::Parameters::PuppetclassLookupKey
|
6
6
|
|
7
7
|
resource_description do
|
8
|
-
api_version '2'
|
9
8
|
api_base_url '/foreman_puppet/api'
|
10
9
|
end
|
11
10
|
|
@@ -3,6 +3,8 @@ module ForemanPuppet
|
|
3
3
|
include Foreman::Controller::AutoCompleteSearch
|
4
4
|
include Foreman::Controller::Parameters::Host
|
5
5
|
include Foreman::Controller::Parameters::Hostgroup
|
6
|
+
include ForemanPuppet::Extensions::ParametersHost
|
7
|
+
include ForemanPuppet::Extensions::ParametersHostgroup
|
6
8
|
include ForemanPuppet::Parameters::Environment
|
7
9
|
include ForemanPuppet::Parameters::Puppetclass
|
8
10
|
include ForemanPuppet::EnvironmentsImport
|
@@ -93,11 +95,11 @@ module ForemanPuppet
|
|
93
95
|
@obj.type = 'Host::Managed'
|
94
96
|
end
|
95
97
|
# puppetclass_ids and config_group_ids need to be removed so they don't cause automatic insertsgroup
|
96
|
-
@obj.attributes = host_params('host')
|
98
|
+
@obj.attributes = host_params('host').tap { |params| strip_relation_ids(params) }
|
97
99
|
elsif params['hostgroup']
|
98
100
|
# hostgroup.id is assigned to params['host_id'] by host_edit.js#load_puppet_class_parameters
|
99
101
|
@obj = Hostgroup.find(host_id)
|
100
|
-
@obj.attributes = hostgroup_params('hostgroup')
|
102
|
+
@obj.attributes = hostgroup_params('hostgroup').tap { |params| strip_relation_ids(params) }
|
101
103
|
end
|
102
104
|
@obj
|
103
105
|
end
|
@@ -110,5 +112,10 @@ module ForemanPuppet
|
|
110
112
|
super
|
111
113
|
end
|
112
114
|
end
|
115
|
+
|
116
|
+
def strip_relation_ids(params)
|
117
|
+
return unless params[:puppet_attributes]
|
118
|
+
params[:puppet_attributes].except!(:puppetclass_ids, :config_group_ids)
|
119
|
+
end
|
113
120
|
end
|
114
121
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanPuppet
|
4
|
+
module Mutations
|
5
|
+
module Hosts
|
6
|
+
module CreateExtensions
|
7
|
+
PUPPET_PARAMS = %i[
|
8
|
+
environment
|
9
|
+
puppetclasses
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
extend ActiveSupport::Concern
|
13
|
+
|
14
|
+
included do
|
15
|
+
argument :environment_id, GraphQL::Types::ID, loads: ForemanPuppet::Types::Environment
|
16
|
+
argument :puppetclass_ids, [GraphQL::Types::ID], loads: ForemanPuppet::Types::Puppetclass, as: :puppetclasses
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def initialize_object(params)
|
21
|
+
host = super(params.except(*PUPPET_PARAMS))
|
22
|
+
host.build_puppet(params.slice(*PUPPET_PARAMS))
|
23
|
+
host
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanPuppet
|
4
|
+
module Types
|
5
|
+
module LocationExtensions
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
has_many :environments, ForemanPuppet::Types::Environment
|
10
|
+
has_many :puppetclasses, ForemanPuppet::Types::Puppetclass
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ForemanPuppet
|
4
|
+
module Types
|
5
|
+
module OrganizationExtensions
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
has_many :environments, ForemanPuppet::Types::Environment
|
10
|
+
has_many :puppetclasses, ForemanPuppet::Types::Puppetclass
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
module Types
|
3
|
+
class Environment < ::Types::BaseObject
|
4
|
+
model_class ForemanPuppet::Environment
|
5
|
+
description 'An Environment'
|
6
|
+
|
7
|
+
global_id_field :id
|
8
|
+
timestamps
|
9
|
+
field :name, String
|
10
|
+
|
11
|
+
has_many :locations, ::Types::Location
|
12
|
+
has_many :organizations, ::Types::Organization
|
13
|
+
has_many :puppetclasses, ForemanPuppet::Types::Puppetclass
|
14
|
+
|
15
|
+
def self.graphql_definition
|
16
|
+
super.tap { |type| type.instance_variable_set(:@name, 'ForemanPuppet::Environment') }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
module Types
|
3
|
+
class Puppetclass < ::Types::BaseObject
|
4
|
+
model_class ForemanPuppet::Puppetclass
|
5
|
+
description 'A Puppetclass'
|
6
|
+
|
7
|
+
global_id_field :id
|
8
|
+
timestamps
|
9
|
+
field :name, String
|
10
|
+
|
11
|
+
has_many :environments, ForemanPuppet::Types::Environment
|
12
|
+
has_many :locations, ::Types::Location
|
13
|
+
has_many :organizations, ::Types::Organization
|
14
|
+
|
15
|
+
def self.graphql_definition
|
16
|
+
super.tap { |type| type.instance_variable_set(:@name, 'ForemanPuppet::Puppetclass') }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -42,7 +42,7 @@ module ForemanPuppet
|
|
42
42
|
mod_name,
|
43
43
|
rel: 'popover',
|
44
44
|
data: { content: mod_classes[mod_name].sort.join('<br>').html_safe,
|
45
|
-
|
45
|
+
'original-title': format(n_('%{name} has %{num_tag} class', '%{name} has %{num_tag} classes', num), name: mod_name, num_tag: num_tag),
|
46
46
|
trigger: 'focus',
|
47
47
|
container: 'body',
|
48
48
|
html: true },
|
@@ -30,7 +30,7 @@ module ForemanPuppet
|
|
30
30
|
|
31
31
|
def link_to_remove_function(text, options)
|
32
32
|
options.delete_if { |key, _value| !options[key].to_s } # otherwise error during template render
|
33
|
-
title = (_('Click to remove %s') % options[:
|
33
|
+
title = (_('Click to remove %s') % options[:'data-class-name'])
|
34
34
|
link_to_function(text, 'tfm.classEditor.removePuppetClass(this)', options.merge!('data-original-title': title))
|
35
35
|
end
|
36
36
|
|
@@ -43,7 +43,7 @@ module ForemanPuppet
|
|
43
43
|
|
44
44
|
def link_to_add_function(text, options)
|
45
45
|
link_to_function(text, 'tfm.classEditor.addPuppetClass(this)',
|
46
|
-
options.merge('data-original-title': _('Click to add %s') % options[:
|
46
|
+
options.merge('data-original-title': _('Click to add %s') % options[:'data-class-name']))
|
47
47
|
end
|
48
48
|
|
49
49
|
def options_for_puppetclass_selection(klass, type)
|
@@ -3,10 +3,14 @@ module ForemanPuppet
|
|
3
3
|
module Host
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
+
include ForemanPuppet::Extensions::HostCommon if ForemanPuppet.extracted_from_core?
|
7
|
+
|
6
8
|
included do
|
7
9
|
prepend PrependedMethods
|
8
10
|
|
9
|
-
|
11
|
+
if ForemanPuppet.extracted_from_core?
|
12
|
+
has_one :environment, through: :puppet, class_name: 'ForemanPuppet::Environment'
|
13
|
+
else
|
10
14
|
env_assoc = reflect_on_association(:environment)
|
11
15
|
env_assoc&.instance_variable_set(:@class_name, 'ForemanPuppet::Environment')
|
12
16
|
|
@@ -80,10 +84,10 @@ module ForemanPuppet
|
|
80
84
|
def available_template_kinds(provisioning = nil)
|
81
85
|
kinds = template_kinds(provisioning)
|
82
86
|
kinds.map do |kind|
|
83
|
-
ProvisioningTemplate.find_template({ kind: kind.name,
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
+
::ProvisioningTemplate.find_template({ kind: kind.name,
|
88
|
+
operatingsystem_id: operatingsystem_id,
|
89
|
+
hostgroup_id: hostgroup_id,
|
90
|
+
environment_id: puppet&.environment_id })
|
87
91
|
end.compact
|
88
92
|
end
|
89
93
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ForemanPuppet
|
2
|
+
module Extensions
|
3
|
+
module HostCommon
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def all_puppetclasses(env = environment)
|
7
|
+
return ForemanPuppet::Puppetclass.none unless puppet
|
8
|
+
puppet.all_puppetclasses(env)
|
9
|
+
end
|
10
|
+
|
11
|
+
def puppetclasses
|
12
|
+
return ForemanPuppet::Puppetclass.none unless puppet
|
13
|
+
puppet.puppetclasses
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|