Class: ForemanProbing::Targeting::Subnet

Inherits:
ForemanProbing::Targeting show all
Defined in:
app/models/foreman_probing/targeting/subnet.rb

Instance Method Summary collapse

Instance Method Details

#subnetObject



7
8
9
# File 'app/models/foreman_probing/targeting/subnet.rb', line 7

def subnet
  @subnet ||= ::Subnet.authorized.find(raw_targets.to_i)
end

#target_kindObject



3
4
5
# File 'app/models/foreman_probing/targeting/subnet.rb', line 3

def target_kind
  'subnet'
end

#targetsObject



11
12
13
14
15
# File 'app/models/foreman_probing/targeting/subnet.rb', line 11

def targets
  # TODO: This is ugly
  cidr = IPAddr.new(subnet.mask).to_i.to_s(2).count('1')
  @targets ||= "#{subnet.network}/#{cidr}"
end