Sha256: 01d82bb121f22df94621c7cfda0571956d7b3f74342f0e94e608aa83bc817ce0

Contents?: true

Size: 681 Bytes

Versions: 13

Compression:

Stored size: 681 Bytes

Contents

module ForemanRemoteExecution
  module NicExtensions
    extend ActiveSupport::Concern

    included do
      before_validation :set_execution_flag
      attr_accessible :execution
      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

13 entries across 13 versions & 1 rubygems

Version Path
foreman_remote_execution-1.0.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.3.2 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.3.1 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.3.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.2.3 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.2.2 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.2.1 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.1.2 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.1.1 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.1.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.0.10 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.0.8 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-0.0.7 app/models/concerns/foreman_remote_execution/nic_extensions.rb