Sha256: 382c7a6e6d1abdc82c0e166e997bba1d05d90308a7542bc974ce899628619bc9

Contents?: true

Size: 648 Bytes

Versions: 56

Compression:

Stored size: 648 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

56 entries across 56 versions & 1 rubygems

Version Path
foreman_remote_execution-2.0.10 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-2.0.9 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-2.0.8 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-3.0.3 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-3.0.2 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-2.0.7 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-3.0.1 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-3.0.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-2.0.6 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-2.0.5 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-2.0.4 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-2.0.3 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-2.0.2 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-2.0.1 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-2.0.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-1.8.4 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-1.8.3 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-1.8.2 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-1.8.1 app/models/concerns/foreman_remote_execution/nic_extensions.rb
foreman_remote_execution-1.8.0 app/models/concerns/foreman_remote_execution/nic_extensions.rb