Sha256: c35dbc4bfac95b97295b6c22a6884bb2acdd7f6beaf0b3a49282868f30712e96

Contents?: true

Size: 649 Bytes

Versions: 37

Compression:

Stored size: 649 Bytes

Contents

module ForemanRemoteExecution
  module NicExtensions
    extend ActiveSupport::Concern

    included do
      before_validation :set_execution_flag
      validate :exclusive_execution_interface
    end

    private

    def set_execution_flag
      return unless primary? && host.present?

      self.execution = true if host.interfaces.detect(&:execution).nil?
    end

    def exclusive_execution_interface
      if host && self.execution?
        executions = host.interfaces.select { |i| i.execution? && i != self }
        errors.add :execution, _('host already has an execution interface') unless executions.empty?
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
foreman_remote_execution-5.0.3 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-6.0.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-5.0.2 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-5.1.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-5.0.1 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-5.0.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.8.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.5.6 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.5.5 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.5.4 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.7.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.5.3 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.5.2 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.5.1 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.6.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.5.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.4.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.3.1 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.3.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-4.2.3 app/models/concerns/foreman_remote_execution/nic_extensions.rb