def dns_server_update
if self.hostname_changed? or self.ip_address_changed?
- @stale_conflicting_nodes = Node.where('id != ? and ip_address = ? and last_ping_at < ?',self.id,self.ip_address,10.minutes.ago)
- if not @stale_conflicting_nodes.empty?
- # One or more stale compute node records have the same IP address as the new node.
- # Clear the ip_address field on the stale nodes.
- @stale_conflicting_nodes.each do |stale_node|
- stale_node.ip_address = nil
- stale_node.save!
+ if not self.ip_address.nil?
+ stale_conflicting_nodes = Node.where('id != ? and ip_address = ? and last_ping_at < ?',self.id,self.ip_address,10.minutes.ago)
+ if not stale_conflicting_nodes.empty?
+ # One or more stale compute node records have the same IP address as the new node.
+ # Clear the ip_address field on the stale nodes.
+ stale_conflicting_nodes.each do |stale_node|
+ stale_node.ip_address = nil
+ stale_node.save!
+ end
end
end
if self.hostname and self.ip_address