'Write a fake lease file to bootstrap dnsmasq.
The generated file is passed to the --dhcp-leasefile option of dnsmasq.
This is used as a bootstrapping mechanism to avoid NAKing active leases
when a dhcp server is scheduled to another agent. Using a leasefile
will also prevent dnsmasq from NAKing or ignoring renewals after a
restart.
Format is as follows:
epoch-timestamp mac_addr ip_addr hostname client-ID'

def _output_init_lease_file(self):

    filename = self.get_conf_file_name('leases')
    buf = six.StringIO()
    LOG.debug('Building    initial    lease    file:    %s', filename)
    if (self.conf.dhcp_lease_duration == (-1)):
        timestamp = 0
    else:
        timestamp = (int(time.time()) + self.conf.dhcp_lease_duration)
    dhcp_enabled_subnet_ids = [s.id for s in self._get_all_subnets(self.network) if s.enable_dhcp]
    for host_tuple in self._iter_hosts():
        (port, alloc, hostname, name, no_dhcp, no_opts) = host_tuple
        if (no_dhcp or (alloc.subnet_id not in dhcp_enabled_subnet_ids)):
            continue
        ip_address = self._format_address_for_dnsmasq(alloc.ip_address)
        buf.write(('%s    %s    %s    *    *\n' % (timestamp, port.mac_address, ip_address)))
    contents = buf.getvalue()
    file_utils.replace_file(filename, contents)
    LOG.debug('Done    building    initial    lease    file    %s    with    contents:\n%s', filename, contents)
    return filename
