Class: Bosh::Director::Models::IpAddress

Inherits:
Object
  • Object
show all
Defined in:
lib/bosh/director/models/ip_address.rb

Instance Method Summary collapse

Instance Method Details

#before_createObject



12
13
14
# File 'lib/bosh/director/models/ip_address.rb', line 12

def before_create
  self.created_at ||= Time.now
end

#infoObject



16
17
18
19
20
# File 'lib/bosh/director/models/ip_address.rb', line 16

def info
  instance_info = "#{self.instance.deployment.name}.#{self.instance.job}/#{self.instance.index}"
  formatted_ip = NetAddr::CIDR.create(self.address).ip
  "#{instance_info} - #{self.network_name} - #{formatted_ip} (#{type})"
end

#typeObject



22
23
24
# File 'lib/bosh/director/models/ip_address.rb', line 22

def type
  self.static ? 'static' : 'dynamic'
end

#validateObject



5
6
7
8
9
10
# File 'lib/bosh/director/models/ip_address.rb', line 5

def validate
  validates_presence :instance_id
  validates_presence :task_id
  validates_presence :address
  validates_unique :address
end