def initial(self, request, *args, **kwargs):
        if self.action in ('update', 'partial_update', 'destroy'):
            instance = self.get_object()
            if instance and instance.state not in instance.States.STABLE_STATES:
                raise core_exceptions.IncorrectStateException(
                    'Modification allowed in stable states only')

        # TODO: Replace it with schedule_transition and common transition flow
        elif self.action in ('stop', 'start', 'resize'):
            instance = self.get_object()
            if instance and instance.state == instance.States.PROVISIONING_SCHEDULED:
                raise core_exceptions.IncorrectStateException(
                    'Provisioning scheduled. Disabled modifications.')

        return super(InstanceViewSet, self).initial(request, *args, **kwargs)
dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/iaas/views.py/InstanceViewSet.initial/original