-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[change] Moved DeviceNode data migration to create_device_nodes command
- Loading branch information
1 parent
7e8b97a
commit c8b3721
Showing
6 changed files
with
37 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
openwisp_network_topology/integrations/device/management/commands/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
5 changes: 5 additions & 0 deletions
5
openwisp_network_topology/integrations/device/management/commands/create_device_nodes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from . import BaseCreateDeviceNodeCommand | ||
|
||
|
||
class Command(BaseCreateDeviceNodeCommand): | ||
pass |
24 changes: 0 additions & 24 deletions
24
openwisp_network_topology/integrations/device/migrations/0002_create_relations.py
This file was deleted.
Oops, something went wrong.
Empty file.
7 changes: 7 additions & 0 deletions
7
tests/openwisp2/sample_integration_device/management/commands/create_device_nodes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |