Skip to content

Commit 392d4c8

Browse files
pandafynemesifier
andauthored
[feature] Implemented device deactivation and reactivation #625 #849
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]>
1 parent e7cd790 commit 392d4c8

39 files changed

+1690
-67
lines changed

docs/developer/utils.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,55 @@ object are changed, but only on ``post_add`` or ``post_remove`` actions,
146146
``post_clear`` is ignored for the same reason explained in the previous
147147
section.
148148

149+
``config_deactivating``
150+
~~~~~~~~~~~~~~~~~~~~~~~
151+
152+
**Path**: ``openwisp_controller.config.signals.config_deactivating``
153+
154+
**Arguments**:
155+
156+
- ``instance``: instance of the object being deactivated
157+
- ``previous_status``: previous status of the object before deactivation
158+
159+
This signal is emitted when a configuration status of device is set to
160+
``deactivating``.
161+
162+
``config_deactivated``
163+
~~~~~~~~~~~~~~~~~~~~~~
164+
165+
**Path**: ``openwisp_controller.config.signals.config_deactivated``
166+
167+
**Arguments**:
168+
169+
- ``instance``: instance of the object being deactivated
170+
- ``previous_status``: previous status of the object before deactivation
171+
172+
This signal is emitted when a configuration status of device is set to
173+
``deactivated``.
174+
175+
``device_deactivated``
176+
~~~~~~~~~~~~~~~~~~~~~~
177+
178+
**Path**: ``openwisp_controller.config.signals.device_deactivated``
179+
180+
**Arguments**:
181+
182+
- ``instance``: instance of the device being deactivated
183+
184+
This signal is emitted when a device is flagged for deactivation.
185+
186+
``device_activated``
187+
~~~~~~~~~~~~~~~~~~~~
188+
189+
**Path**: ``openwisp_controller.config.signals.device_activated``
190+
191+
**Arguments**:
192+
193+
- ``instance``: instance of the device being activated
194+
195+
This signal is emitted when a device is flagged for activation (after
196+
deactivation).
197+
149198
.. _config_backend_changed:
150199

151200
``config_backend_changed``

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ the OpenWISP architecture.
3535
:maxdepth: 1
3636

3737
user/intro.rst
38+
user/device-config-status.rst
3839
user/templates.rst
3940
user/variables.rst
4041
user/device-groups.rst

docs/user/device-config-status.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Device Configuration Status
2+
===========================
3+
4+
The device's configuration status (`Device.config.status`) indicates the
5+
current state of the configuration as managed by OpenWISP. The possible
6+
statuses and their meanings are explained below.
7+
8+
``modified``
9+
------------
10+
11+
The device configuration has been updated in OpenWISP, but these changes
12+
have not yet been applied to the device. The device is pending an update.
13+
14+
``applied``
15+
-----------
16+
17+
The device has successfully applied the configuration changes made in
18+
OpenWISP. The current configuration on the device matches the latest
19+
changes.
20+
21+
``error``
22+
---------
23+
24+
An issue occurred while applying the configuration to the device, causing
25+
the device to revert to its previous working configuration.
26+
27+
``deactivating``
28+
----------------
29+
30+
The device is in the process of being deactivated. The configuration is
31+
scheduled to be removed from the device.
32+
33+
``deactivated``
34+
---------------
35+
36+
The device has been deactivated. The configuration applied through
37+
OpenWISP has been removed, and any other operation to manage the device
38+
will be prevented or rejected.

docs/user/rest-api.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,29 @@ from the config of a device,
233233
Delete Device
234234
~~~~~~~~~~~~~
235235

236+
.. note::
237+
238+
A device must be deactivated before it can be deleted. Otherwise, an
239+
``HTTP 403 Forbidden`` response will be returned.
240+
236241
.. code-block:: text
237242
238243
DELETE /api/v1/controller/device/{id}/
239244
245+
Deactivate Device
246+
~~~~~~~~~~~~~~~~~
247+
248+
.. code-block:: text
249+
250+
POST /api/v1/controller/device/{id}/deactivate/
251+
252+
Activate Device
253+
~~~~~~~~~~~~~~~
254+
255+
.. code-block:: text
256+
257+
POST /api/v1/controller/device/{id}/activate/
258+
240259
List Device Connections
241260
~~~~~~~~~~~~~~~~~~~~~~~
242261

0 commit comments

Comments
 (0)