Skip to content

Commit 0477aea

Browse files
authored
Merge branch 'master' into feature/894-rest-api-revisions
2 parents 98ca619 + 4881326 commit 0477aea

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

openwisp_controller/config/base/vpn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ def auto_client(self, auto_cert=True, template_backend_class=None):
634634
# call auto_client and update the config
635635
elif self._is_backend_type('zerotier') and template_backend_class:
636636
auto = getattr(template_backend_class, 'zerotier_auto_client')(
637-
name='ow_zt',
637+
name='global',
638638
networks=[
639639
{'id': self.network_id, 'ifname': f'owzt{self.network_id[-6:]}'}
640640
],
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from django.db import migrations
2+
3+
4+
def change_owzt_to_global(apps, schema_editor):
5+
Template = apps.get_model('config', 'Template')
6+
updated_templates = set()
7+
for template in Template.objects.filter(
8+
type='vpn', vpn__backend='openwisp_controller.vpn_backends.ZeroTier'
9+
).iterator():
10+
if 'zerotier' in template.config:
11+
for item in template.config.get('zerotier', []):
12+
if item.get('name') == 'ow_zt':
13+
item['name'] = 'global'
14+
updated_templates.add(template)
15+
Template.objects.bulk_update(updated_templates, ['config'])
16+
17+
18+
class Migration(migrations.Migration):
19+
dependencies = [('config', '0058_alter_vpnclient_template')]
20+
21+
operations = [
22+
migrations.RunPython(
23+
change_owzt_to_global, reverse_code=migrations.RunPython.noop
24+
)
25+
]

openwisp_controller/config/tests/test_vpn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,7 @@ def test_zerotier_auto_client(self, mock_requests, mock_subprocess):
12281228
for key in context_keys.keys():
12291229
context_keys[key] = '{{%s}}' % context_keys[key]
12301230
expected = template.backend_class.zerotier_auto_client(
1231-
name='ow_zt',
1231+
name='global',
12321232
networks=[{'id': vpn.network_id, 'ifname': f'owzt{vpn.network_id[-6:]}'}],
12331233
identity_secret=context_keys['secret'],
12341234
)

0 commit comments

Comments
 (0)