@detail_route(methods=['post'])
    def assign_floating_ip(self, request, uuid):
        """
        Assign floating IP to the instance.
        """
        instance = self.get_object()

        serializer = serializers.AssignFloatingIpSerializer(instance, data=request.data)
        serializer.is_valid(raise_exception=True)

        if not instance.cloud_project_membership.external_network_id:
            return Response({'detail': 'External network ID of the cloud project membership is missing.'},
                            status=status.HTTP_409_CONFLICT)
        elif instance.cloud_project_membership.state in SynchronizationStates.UNSTABLE_STATES:
            return Response({'detail': 'Cloud project membership of instance should be in stable state.'},
                            status=status.HTTP_409_CONFLICT)
        elif instance.state in models.Instance.States.UNSTABLE_STATES:
            raise core_exceptions.IncorrectStateException(
                detail='Cannot add floating IP to instance in unstable state.')

        tasks.assign_floating_ip.delay(serializer.validated_data['floating_ip_uuid'], uuid)
        return Response({'detail': 'Assigning floating IP to the instance has been scheduled.'},
                        status=status.HTTP_202_ACCEPTED)
dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/iaas/views.py/InstanceViewSet.assign_floating_ip/original