Skip to content

Commit

Permalink
[feature] Implemented device deactivation and reactivation #625 #849
Browse files Browse the repository at this point in the history
Closes #625
Closes #849

* [feature] Do not delete related Certs when device is deactivated
* [feature] Set device status to deactivated if current status is deactivating
* [feature] Return 404 checksum for deactivated devices
* [feature] Added activate and deactivate button on the device page
* [feature] Added "config_deactivating" signal
* [change] Show delete action after deactivate action
* [feature] Emit device_deactivated signal when device is deactivated
* [fix] Don't show any extra form on deactivated devices
* [change] Clear management IP after the device is deactivated
* [change] Added API endpoints for activating/deactivating device
* [change] Updated device delete API endpoint
* [change] Disable API operations on deactivated devices
* [feature] Added "device_activated" signal
* [docs] Updated docs
* [fix] Don't allow PUT/PATCH request for deactivated device

---------

Co-authored-by: Federico Capoano <[email protected]>
  • Loading branch information
pandafy and nemesifier authored Nov 19, 2024
1 parent e7cd790 commit 392d4c8
Show file tree
Hide file tree
Showing 39 changed files with 1,690 additions and 67 deletions.
49 changes: 49 additions & 0 deletions docs/developer/utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,55 @@ object are changed, but only on ``post_add`` or ``post_remove`` actions,
``post_clear`` is ignored for the same reason explained in the previous
section.

``config_deactivating``
~~~~~~~~~~~~~~~~~~~~~~~

**Path**: ``openwisp_controller.config.signals.config_deactivating``

**Arguments**:

- ``instance``: instance of the object being deactivated
- ``previous_status``: previous status of the object before deactivation

This signal is emitted when a configuration status of device is set to
``deactivating``.

``config_deactivated``
~~~~~~~~~~~~~~~~~~~~~~

**Path**: ``openwisp_controller.config.signals.config_deactivated``

**Arguments**:

- ``instance``: instance of the object being deactivated
- ``previous_status``: previous status of the object before deactivation

This signal is emitted when a configuration status of device is set to
``deactivated``.

``device_deactivated``
~~~~~~~~~~~~~~~~~~~~~~

**Path**: ``openwisp_controller.config.signals.device_deactivated``

**Arguments**:

- ``instance``: instance of the device being deactivated

This signal is emitted when a device is flagged for deactivation.

``device_activated``
~~~~~~~~~~~~~~~~~~~~

**Path**: ``openwisp_controller.config.signals.device_activated``

**Arguments**:

- ``instance``: instance of the device being activated

This signal is emitted when a device is flagged for activation (after
deactivation).

.. _config_backend_changed:

``config_backend_changed``
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ the OpenWISP architecture.
:maxdepth: 1

user/intro.rst
user/device-config-status.rst
user/templates.rst
user/variables.rst
user/device-groups.rst
Expand Down
38 changes: 38 additions & 0 deletions docs/user/device-config-status.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
Device Configuration Status
===========================

The device's configuration status (`Device.config.status`) indicates the
current state of the configuration as managed by OpenWISP. The possible
statuses and their meanings are explained below.

``modified``
------------

The device configuration has been updated in OpenWISP, but these changes
have not yet been applied to the device. The device is pending an update.

``applied``
-----------

The device has successfully applied the configuration changes made in
OpenWISP. The current configuration on the device matches the latest
changes.

``error``
---------

An issue occurred while applying the configuration to the device, causing
the device to revert to its previous working configuration.

``deactivating``
----------------

The device is in the process of being deactivated. The configuration is
scheduled to be removed from the device.

``deactivated``
---------------

The device has been deactivated. The configuration applied through
OpenWISP has been removed, and any other operation to manage the device
will be prevented or rejected.
19 changes: 19 additions & 0 deletions docs/user/rest-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,29 @@ from the config of a device,
Delete Device
~~~~~~~~~~~~~

.. note::

A device must be deactivated before it can be deleted. Otherwise, an
``HTTP 403 Forbidden`` response will be returned.

.. code-block:: text
DELETE /api/v1/controller/device/{id}/
Deactivate Device
~~~~~~~~~~~~~~~~~

.. code-block:: text
POST /api/v1/controller/device/{id}/deactivate/
Activate Device
~~~~~~~~~~~~~~~

.. code-block:: text
POST /api/v1/controller/device/{id}/activate/
List Device Connections
~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
Loading

0 comments on commit 392d4c8

Please sign in to comment.