Project

General

Profile

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

foreman-docker / app / models / foreman_docker / dns.rb @ cc6d0d73

1
require 'resolv'
2

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

    
11
    belongs_to :container, :foreign_key => :reference_id,
12
                           :inverse_of => :dns,
13
                           :class_name => "Container"
14

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