Module: ForemanPuppet::Extensions::ParametersHostgroup

Extended by:
ActiveSupport::Concern
Included in:
PuppetclassesController
Defined in:
app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb

Defined Under Namespace

Modules: PatchedClassMethods, PatchedMethods

Instance Method Summary collapse

Instance Method Details

#process_deprecated_hostgroup_attributes!(params, top_level_hash = 'hostgroup') ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb', line 58

def process_deprecated_hostgroup_attributes!(params, top_level_hash = 'hostgroup')
  %w[puppetclass config_group].each do |relation|
    ids = params.delete("#{relation}_ids")
    names = params.delete("#{relation}_names")

    next unless ids || names
    ::Foreman::Deprecation.api_deprecation_warning("param #{top_level_hash}[#{relation}_*] has been deprecated in favor of #{top_level_hash}[puppet_attributes][#{relation}_*]")

    params[:puppet_attributes] ||= {}
    params[:puppet_attributes]["#{relation}_ids".to_sym] ||= ids if ids
    params[:puppet_attributes]["#{relation}_names".to_sym] ||= names if names
  end
end

#process_deprecated_hostgroup_environment_params!(params, top_level_hash = 'hostgroup') ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb', line 46

def process_deprecated_hostgroup_environment_params!(params, top_level_hash = 'hostgroup')
  env_id = params.delete(:environment_id)
  env_name = params.delete(:environment_name)

  return unless env_id || env_name
  ::Foreman::Deprecation.api_deprecation_warning("param #{top_level_hash}[environment_*] has been deprecated in favor of #{top_level_hash}[puppet_attributes][environment_*]")

  params[:puppet_attributes] ||= {}
  params[:puppet_attributes][:environment_id] ||= env_id if env_id
  params[:puppet_attributes][:environment_name] ||= env_name if env_name
end

#process_deprecated_hostgroup_puppet_params!(params, top_level_hash = 'hostgroup') ⇒ Object



41
42
43
44
# File 'app/controllers/concerns/foreman_puppet/extensions/parameters_hostgroup.rb', line 41

def process_deprecated_hostgroup_puppet_params!(params, top_level_hash = 'hostgroup')
  process_deprecated_hostgroup_environment_params!(params, top_level_hash)
  process_deprecated_hostgroup_attributes!(params, top_level_hash)
end