def allocate_for_instance(self, context, **kwargs):
        instance_id = kwargs.get('instance_id')
        project_id = kwargs.get('project_id')
        requested_networks = kwargs.get('requested_networks')
        LOG.debug(_("floating IP allocation for instance |%s|"), instance_id,
                                                               context=context)
        # call the next inherited class's allocate_for_instance()
        # which is currently the NetworkManager version
        # do this first so fixed ip is already allocated
        ips = super(FloatingIP, self).allocate_for_instance(context, **kwargs)
        if FLAGS.auto_assign_floating_ip:
            # allocate a floating ip (public_ip is just the address string)
            public_ip = self.allocate_floating_ip(context, project_id)
            # set auto_assigned column to true for the floating ip
            self.db.floating_ip_set_auto_assigned(context, public_ip)
            # get the floating ip object from public_ip string
            floating_ip = self.db.floating_ip_get_by_address(context,
                                                             public_ip)

            # get the first fixed_ip belonging to the instance
            fixed_ips = self.db.fixed_ip_get_by_instance(context, instance_id)
            fixed_ip = fixed_ips[0] if fixed_ips else None

            # call to correct network host to associate the floating ip
            self.network_api.associate_floating_ip(context,
                                              floating_ip['address'],
                                              fixed_ip['address'],
                                              affect_auto_assigned=True)
        return ips
Handles allocating the floating IP resources for an instance.
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/network/manager.py/FloatingIP.allocate_for_instance