Sha256: dc4434828fd5646c74b899744b952a222f974c544b5297f4b36004badb28476b

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

# various methods which gets added to the puppetclasses and environments controllers

module Foreman::Controller::Environments

  def import_environments
    begin
      opts      = params[:proxy].blank? ? { } : { :url => SmartProxy.find(params[:proxy]).try(:url) }
      @importer = PuppetClassImporter.new(opts)
      @changed  = @importer.changes
    rescue => e
      if e.message =~ /puppet feature/i
        error "We did not find a foreman proxy that can provide the information, ensure that you have at least one Proxy with the puppet feature turned on."
        redirect_to :controller => controller_path and return
      else
        raise e
      end
    end

    if @changed["new"].size > 0 or @changed["obsolete"].size > 0 or @changed["updated"].size > 0
      render "common/_puppetclasses_or_envs_changed"
    else
      notice "No changes to your environments detected"
      redirect_to :controller => controller_path
    end
  end

  def obsolete_and_new
    if (errors = ::PuppetClassImporter.new.obsolete_and_new(params[:changed])).empty?
      notice "Successfully updated environments and puppetclasses from the on-disk puppet installation"
    else
      error "Failed to update the environments and puppetclasses from the on-disk puppet installation<br/>" + errors.join("<br>")
    end
    redirect_to :controller => controller_path
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/lib/foreman/controller/environments.rb
foreman_discovery-1.0.0.rc4 test/foreman_app/lib/foreman/controller/environments.rb
foreman_discovery-1.0.0.rc3 test/foreman_app/lib/foreman/controller/environments.rb
foreman_discovery-1.0.0.rc2 test/foreman_app/lib/foreman/controller/environments.rb
foreman_discovery-1.0.0.rc1 test/foreman_app/lib/foreman/controller/environments.rb