class Proxy::DHCP::BlueCat::Provider

this class handles commuincation from foreman

Attributes

connection[R]

Public Class Methods

new(connection, managed_subnets) click to toggle source
Calls superclass method
# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 13
def initialize(connection, managed_subnets)
  @connection = connection
  @managed_subnets = managed_subnets
  super("bluecat", managed_subnets, nil)
end

Public Instance Methods

add_record(options) click to toggle source

adds a host record

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 114
def add_record(options)
  logger.debug("START add_record with options: #{options}")
  @connection.add_host(options)
  logger.debug("END add_record with options: #{options}")
end
all_hosts(network_address) click to toggle source

returns all hosts in a subnet in bluecat leases and hosts are the same

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 30
def all_hosts(network_address)
  logger.debug("START all_hosts with network_address: #{network_address}")
  hosts = @connection.hosts(network_address)
  logger.debug("END all_hosts with network_address: #{network_address}")
  logger.debug("Returned: #{hosts.class}: #{hosts}")
  hosts
end
all_leases(network_address) click to toggle source

returns all leases in a subnet in bluecat leases and hosts are the same

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 40
def all_leases(network_address)
  logger.debug("START all_leases with network_address: #{network_address}")
  hosts = @connection.hosts(network_address)
  logger.debug("END all_leases with network_address: #{network_address}")
  logger.debug("Returned: #{hosts.class}: #{hosts}")
  hosts
end
del_record(record) click to toggle source

removes a host record

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 121
def del_record(record)
  logger.debug("START del_record with record: #{record}")
  if record.empty?
    logger.debug("record empty, nothing to do")
  else
    @connection.remove_host(record.ip)
  end
  logger.debug("END del_record with record: #{record}")
end
find_record(subnet_address, address) click to toggle source

returns a record foreman calls this method with a ip or a mac address

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 61
def find_record(subnet_address, address)
  logger.debug("START find_record with subnet_address: #{net} address: #{address}")
  if IPAddress.valid?(address)
    records = find_records_by_ip(subnet_address, address)
  else
    records = find_record_by_mac(subnet_address, address)
  end
  logger.debug("END find_record with subnet_address: #{subnet_address} address: #{address}")
  logger.debug("Returned: #{records.class}: #{records}")
  return [] if records.nil?

  records
end
find_record_by_mac(subnet_address, mac_address) click to toggle source

returns a record based on a mac address

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 87
def find_record_by_mac(subnet_address, mac_address)
  logger.debug("START find_record_by_mac with subnet_address: #{subnet_address} mac_address: #{mac_address}")
  record = @connection.host_by_mac_and_subnet(subnet_address, mac_address)
  logger.debug("END find_record_by_mac with subnet_address: #{subnet_address} mac_address: #{mac_address}")
  logger.debug("Returned: #{record.class}: #{record}")
  record
end
find_records_by_ip(subnet_address, ip) click to toggle source

returns a record based on a ip address

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 76
def find_records_by_ip(subnet_address, ip)
  logger.debug("START find_records_by_ip with subnet_address: #{subnet_address} ip: #{ip}")
  records = @connection.hosts_by_ip(ip)
  logger.debug("END find_records_by_ip with subnet_address: #{subnet_address} ip: #{ip}")
  logger.debug("Returned: #{records.class}: #{records}")
  return [] if records.nil?

  records
end
find_subnet(subnet_address) click to toggle source

returns a subnet based on a subnet address

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 96
def find_subnet(subnet_address)
  logger.debug("START find_subnet with subnet_address: #{subnet_address}")
  net = @connection.find_mysubnet(subnet_address)
  logger.debug("END find_subnet with subnet_address: #{subnet_address}")
  logger.debug("Returned: #{net.class}: #{net}")
  net
end
get_subnet(subnet_address) click to toggle source

returns a subnet based on a subnet address

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 105
def get_subnet(subnet_address)
  logger.debug("START get_subnet with subnet_address: #{subnet_address}")
  net = @connection.find_mysubnet(subnet_address)
  logger.debug("END get_subnet with subnet_address: #{subnet_address}")
  logger.debug("Returned: #{net.class}: #{net}")
  net
end
subnets() click to toggle source

returns all subnets

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 20
def subnets
  logger.debug("START subnets")
  subnets = @connection.subnets
  logger.debug("END subnets")
  logger.debug("Returned: #{subnets.class}: #{subnets}")
  subnets
end
unused_ip(subnet, mac_address, from_ip_address, to_ip_address) click to toggle source

returns the next free ip in a subnet

# File lib/smart_proxy_dhcp_bluecat/dhcp_bluecat_main.rb, line 49
def unused_ip(subnet, mac_address, from_ip_address, to_ip_address)
  logger.debug("START unused_ip with subnet: #{subnet} mac_address: #{mac_address} \
                from_ip_address: #{from_ip_address} to_ip_address: #{to_ip_address}")
  ip = @connection.next_ip(subnet, from_ip_address, to_ip_address)
  logger.debug("END unused_ip with subnet: #{subnet} mac_address: #{mac_address} \
                from_ip_address: #{from_ip_address} to_ip_address: #{to_ip_address}")
  logger.debug("Returned: #{ip.class}: #{ip}")
  ip
end