Esempio n. 1
0
 def get_v4_ips_by_interface(self, context, net_id, vif_id, project_id):
     """Returns a list of IPv4 address strings associated with
        the specified virtual interface, based on the fixed_ips table.
     """
     vif_rec = db.virtual_interface_get_by_uuid(context, vif_id)
     fixed_ips = db.fixed_ips_by_virtual_interface(context,
                                                      vif_rec['id'])
     return [fixed_ip['address'] for fixed_ip in fixed_ips]
Esempio n. 2
0
 def get_dhcp_hosts_text(self, context, subnet_id, project_id=None):
     ips = self.ipam.get_allocated_ips(context, subnet_id, project_id)
     hosts_text = ""
     admin_context = context.elevated()
     for ip in ips:
         address, vif_id = ip
         vif = db.virtual_interface_get_by_uuid(admin_context, vif_id)
         mac_address = vif['address']
         text = "%s,%s.%s,%s\n" % (mac_address, "host-" + address,
             FLAGS.dhcp_domain, address)
         hosts_text += text
     LOG.debug("DHCP hosts: %s" % hosts_text)
     return hosts_text
Esempio n. 3
0
 def get_v6_ips_by_interface(self, context, net_id, vif_id, project_id):
     """Returns a list containing a single IPv6 address strings
        associated with the specified virtual interface.
     """
     admin_context = context.elevated()
     network = db.network_get_by_uuid(admin_context, net_id)
     vif_rec = db.virtual_interface_get_by_uuid(context, vif_id)
     if network['cidr_v6']:
         ip = ipv6.to_global(network['cidr_v6'],
                             vif_rec['address'],
                             project_id)
         return [ip]
     return []
Esempio n. 4
0
 def get_dhcp_leases(self, context, network_ref):
     """Return a network's hosts config in dnsmasq leasefile format."""
     subnet_id = network_ref['uuid']
     project_id = network_ref['project_id']
     ips = self.ipam.get_allocated_ips(context, subnet_id, project_id)
     leases_text = ""
     admin_context = context.elevated()
     for ip in ips:
         address, vif_id = ip
         vif = db.virtual_interface_get_by_uuid(admin_context, vif_id)
         mac_address = vif['address']
         text = "%s %s %s %s *\n" % \
             (int(time.time()) - FLAGS.dhcp_lease_time,
              mac_address, address, '*')
         leases_text += text
     LOG.debug("DHCP leases: %s" % leases_text)
     return leases_text