'Gets a fixed IP from the pool.'

def allocate_fixed_ip(self, context, instance_id, network, **kwargs):

    LOG.debug('Allocate    fixed    IP    on    network    %s', network['uuid'], instance_uuid=instance_id)
    vif = objects.VirtualInterface.get_by_instance_and_network(context, instance_id, network['id'])
    if (vif is None):
        LOG.debug('vif    for    network    %(network)s    and    instance    %(instance_id)s    is    used    up,    trying    to    create    new    vif', {'network': network['id'], 'instance_id': instance_id})
        vif = self._add_virtual_interface(context, instance_id, network['id'])
    if kwargs.get('vpn', None):
        address = network['vpn_private_address']
        fip = objects.FixedIP.associate(context, str(address), instance_id, network['id'], reserved=True, vif_id=vif.id)
    else:
        address = kwargs.get('address', None)
        if address:
            fip = objects.FixedIP.associate(context, str(address), instance_id, network['id'], vif_id=vif.id)
        else:
            fip = objects.FixedIP.associate_pool(context, network['id'], instance_id, vif_id=vif.id)
    address = fip.address
    if (not kwargs.get('vpn', None)):
        self._do_trigger_security_group_members_refresh_for_instance(instance_id)
    instance = objects.Instance.get_by_uuid(context, instance_id)
    name = instance.display_name
    if self._validate_instance_zone_for_dns_domain(context, instance):
        self.instance_dns_manager.create_entry(name, address, 'A', self.instance_dns_domain)
        self.instance_dns_manager.create_entry(instance_id, address, 'A', self.instance_dns_domain)
    self._setup_network_on_host(context, network)
    LOG.debug('Allocated    fixed    IP    %s    on    network    %s', address, network['uuid'], instance=instance)
    return address
