Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion openwisp_controller/config/base/vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ def auto_client(self, auto_cert=True, template_backend_class=None):
# call auto_client and update the config
elif self._is_backend_type('zerotier') and template_backend_class:
auto = getattr(template_backend_class, 'zerotier_auto_client')(
name='ow_zt',
name='global',
networks=[
{'id': self.network_id, 'ifname': f'owzt{self.network_id[-6:]}'}
],
Expand Down
24 changes: 24 additions & 0 deletions openwisp_controller/config/migrations/0056_ow_zt_to_global.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.db import migrations


def change_owzt_to_global(apps, schema_editor):
Template = apps.get_model('config', 'Template')
updated_templates = set()
for template in Template.objects.filter(
type='vpn', vpn__backend='openwisp_controller.vpn_backends.ZeroTier'
).iterator():
if 'zerotier' in template.config:
for item in template.config.get('zerotier', []):
if item.get('name') == 'ow_zt':
item['name'] = 'global'
updated_templates.add(template)
Template.objects.bulk_update(updated_templates, ['config'])


class Migration(migrations.Migration):
dependencies = [('config', '0055_alter_config_status')]

operations = [
migrations.RunPython(
change_owzt_to_global, reverse_code=migrations.RunPython.noop)
]
2 changes: 1 addition & 1 deletion openwisp_controller/config/tests/test_vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ def test_zerotier_auto_client(self, mock_requests, mock_subprocess):
for key in context_keys.keys():
context_keys[key] = '{{%s}}' % context_keys[key]
expected = template.backend_class.zerotier_auto_client(
name='ow_zt',
name='global',
networks=[{'id': vpn.network_id, 'ifname': f'owzt{vpn.network_id[-6:]}'}],
identity_secret=context_keys['secret'],
)
Expand Down
Loading