Project

General

Profile

Download (1.03 KB) Statistics
| Branch: | Tag: | Revision:

foreman-docker / app / models / foreman_docker / dns.rb @ 26c5ba32

1
require 'resolv'
2

    
3
module ForemanDocker
4
  class Dns < Parameter
5
    attr_accessible :priority
6

    
7
    # The Parameter class from which this Dns class inherits,validates for the
8
    # presence of an associated domain,  operating system, host or host group.
9
    # We will have to reset those validations for the Dns class as they do not
10
    # make any sense for the context in which this class is being used here.
11
    ForemanDocker::Dns.reset_callbacks(:validate)
12

    
13
    belongs_to :container, :foreign_key => :reference_id,
14
                           :inverse_of => :dns,
15
                           :class_name => "Container"
16

    
17
    audited :except => [:priority], :associated_with => :container, :allow_mass_assignment => true
18
    validates :name, :uniqueness => { :scope => :reference_id },
19
                     :format => {
20
                       :with => Regexp.union(Resolv::IPv4::Regex,
21
                                             Resolv::IPv6::Regex,
22
                                             /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}$/) }
23
  end
24
end