Project

General

Profile

noclass.patch

Nacho Barrientos, 05/04/2021 01:32 PM

View differences:

app/services/puppet_class_importer.rb
2 2
  def initialize(args = { })
3 3
    @foreman_classes = { }
4 4
    @proxy_classes   = { }
5
    # == CERN Local patch ==
6
    # Keep a cache to avoid hammering the proxy, as the importer gets
7
    # all the environments from the proxy several times during the
8
    # import process.
9
    @proxy_envs = nil
5 10
    @environment = args[:env]
6 11
    if args[:proxy]
......
24 29
        changes_for_environment(env, changes)
25 30
      end
31
      # == CERN Local patch ==
32
      # New environments are only created if classes can be imported
33
      # for them. As we don't import classes, we have to force listing
34
      # here the environments that are considered new so they're
35
      # created.
36
      new_environments.each do |env|
37
        changes['new'][env] ||= {}
38
      end
39

  
26 40
      old_environments.each do |env|
27 41
        changes['obsolete'][env] ||= []
28 42
        changes['obsolete'][env] << "_destroy_" unless actual_environments.include?(env)
......
89 103
  #  * +environment+: {String} containing the name of the environment
90 104
  #
91 105
  def proxy_classes_for(environment)
92
    @proxy_classes[environment] ||= proxy.classes(environment)
106
    # == CERN Local patch ==
107
    # We don't do class assignment in Foreman so there's no need to
108
    # import all the classes for each environment. This is a very slow
109
    # operation (call to puppet/v3/environment_classes) that we can
110
    # avoid.
111
    {}
93 112
  end
94 113
  def new_classes_for(environment)
......
175 194
  end
176 195
  def proxy_environments
177
    proxy.environments.map(&:to_s)
196
    # == CERN Local patch ==
197
    # Keep a cache to avoid hammering the proxy, as the importer gets
198
    # all the environments from the proxy several times during the
199
    # import process.
200
    @proxy_envs ||= proxy.environments.map(&:to_s)
178 201
  end
179 202
  def to_be_created_environments