Skip to content

Commit

Permalink
[change] Moved DeviceNode migration to create_device_nodes command #92
Browse files Browse the repository at this point in the history
Closes #92
  • Loading branch information
NoumbissiValere committed Sep 17, 2020
1 parent 7e8b97a commit d711d1e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 24 deletions.
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,16 @@ by default the data is added to the first found organization, eg::

**Note**: you can follow the `tutorial to migrate database from django-netjsongraph <https://github.com/openwisp/django-netjsongraph/blob/master/README.rst>`_.

create_device_nodes
^^^^^^^^^^^^^^^^^^^

The ``create_device_nodes`` management command is used to create ``DeviceNode`` objects when
this module is integrated with ``openwisp_controller``. It can be used as follows:

.. code-block:: shell
./manage.py create_device_nodes
Logging
-------

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import swapper
from django.core.management.base import BaseCommand


class BaseCreateDeviceNodeCommand(BaseCommand):
help = 'Create initial DeviceNode objects'

def handle(self, *args, **kwargs):
Node = swapper.load_model('topology', 'Node')
DeviceNode = swapper.load_model('topology_device', 'DeviceNode')
queryset = Node.objects.select_related('topology').filter(
topology__parser='netdiff.OpenvpnParser'
)
for node in queryset.iterator():
DeviceNode.auto_create(node)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from . import BaseCreateDeviceNodeCommand


class Command(BaseCreateDeviceNodeCommand):
pass

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from openwisp_network_topology.integrations.device.management.commands import (
BaseCreateDeviceNodeCommand,
)


class Command(BaseCreateDeviceNodeCommand):
pass

0 comments on commit d711d1e

Please sign in to comment.