Sha256: 925e19f15a65a70a246f32d296f7f6898a64ab8130efc171349ca85c784e13d1

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

#
# Copyright 2014 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public
# License as published by the Free Software Foundation; either version
# 2 of the License (GPLv2) or (at your option) any later version.
# There is NO WARRANTY for this software, express or implied,
# including the implied warranties of MERCHANTABILITY,
# NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should
# have received a copy of GPLv2 along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.

module Katello
  class Foreman
    def self.build_puppet_environment(org, env, content_view)
      unless content_view.default?
        Environment.find_or_build_by_katello_id(org, env, content_view)
      end
    end

    def self.update_puppet_environment(content_view, environment)
      content_view_puppet_env = content_view.version(environment).puppet_env(environment)
      if !content_view.default? && content_view_puppet_env
        foreman_environment = content_view_puppet_env.puppet_environment

        # Associate the puppet environment with the locations that are currently
        # associated with the capsules that have the target lifecycle environment.
        capsule_contents = Katello::CapsuleContent.with_environment(environment, true)
        unless capsule_contents.blank?
          locations = capsule_contents.map(&:capsule).map(&:locations).compact.flatten.uniq
          foreman_environment.locations = locations
          foreman_environment.save!
        end

        if (foreman_smart_proxy = SmartProxy.default_capsule)
          PuppetClassImporter.new(:url => foreman_smart_proxy.url, :env => foreman_environment.name).update_environment
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
katello-2.2.2 app/lib/katello/foreman.rb