Example #1
0
 def allocate_fixed_ip(self, context, tenant_id, quantum_net_id, vif_rec):
     """Allocates a single fixed IPv4 address for a virtual interface."""
     admin_context = context.elevated()
     network = db.network_get_by_uuid(admin_context, quantum_net_id)
     address = None
     if network['cidr']:
         address = db.fixed_ip_associate_pool(admin_context,
                                              network['id'],
                                              vif_rec['instance_id'])
         values = {'allocated': True,
                   'virtual_interface_id': vif_rec['id']}
         db.fixed_ip_update(admin_context, address, values)
     return address
Example #2
0
 def deallocate_ips_by_vif(self, context, tenant_id, net_id, vif_ref):
     """Deallocate all fixed IPs associated with the specified
        virtual interface.
     """
     admin_context = context.elevated()
     fixed_ips = db.fixed_ips_by_virtual_interface(admin_context,
                                                      vif_ref['id'])
     for fixed_ip in fixed_ips:
         db.fixed_ip_update(admin_context, fixed_ip['address'],
                            {'allocated': False,
                             'virtual_interface_id': None})
     if len(fixed_ips) == 0:
         LOG.error(_('No fixed IPs to deallocate for vif %s' %
                     vif_ref['id']))