Sha256: 7c549921c55b8fb2845e7365d483408dd495bfe80d8b67c32ec5455533fc9966

Contents?: true

Size: 1.31 KB

Versions: 31

Compression:

Stored size: 1.31 KB

Contents

module ForemanAnsible
  module SmartProxiesHelper
    def can_update_proxy?(proxy)
      hosts = proxy.smart_proxy_hosts

      return if !can_schedule_jobs? ||
                hosts.empty? ||
                !hosts.all? { |host| can_execute_on_host?(host) }

      begin
        version = proxy.statuses[:version].version
      rescue Foreman::Exception
        return false
      end

      foreman_version = Foreman::Version.new
      proxy_version = Foreman::Version.new(version['version'])

      foreman_major = foreman_version.major.to_i
      foreman_minor = foreman_version.minor.to_i

      proxy_major = proxy_version.major.to_i
      proxy_minor = proxy_version.minor.to_i

      foreman_major > proxy_major ||
        (foreman_major == proxy_major && foreman_minor > proxy_minor)
    end

    def proxy_update_button(proxy)
      name = if Foreman::Plugin.find('foreman_theme_satellite').present?
               :ansible_run_capsule_upgrade
             else
               :ansible_run_smart_proxy_upgrade
             end

      feature = RemoteExecutionFeature.feature(name)
      return if feature.nil?

      path = new_job_invocation_path(:host_ids => proxy.infrastructure_host_facets.pluck(:host_id),
                                     :feature => feature.label)
      link_to(_('Upgrade'), path)
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
foreman_ansible-15.0.2 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-15.0.1 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-15.0.0 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-14.2.2 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-14.2.1 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-13.0.7 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-14.2.0 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-14.1.1 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-14.1.0 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-13.0.5 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-14.0.0 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-13.0.4 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-13.0.3 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-13.0.2 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-13.0.1 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-13.0.0 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-12.0.7 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-10.4.4 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-12.0.6 app/helpers/foreman_ansible/smart_proxies_helper.rb
foreman_ansible-12.0.5 app/helpers/foreman_ansible/smart_proxies_helper.rb