Skip to content

Commit 5088a1c

Browse files
Implemented change zerotier network name from ow_zt to global
1 parent aba8beb commit 5088a1c

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from django.db import migrations
2+
import json
3+
4+
def change_owzt_to_global(apps):
5+
Template = apps.get_model('config', 'Template')
6+
for template in Template.objects.all():
7+
config = json.loads(template.config)
8+
if 'zerotier' in config:
9+
for item in config.get('zerotier',[]):
10+
if item.get('name') == 'ow_zt':
11+
item['name'] = 'global'
12+
13+
class Migration(migrations.Migration):
14+
dependencies = [('config', '0056_ow_zt-to-global')]
15+
16+
operations = [
17+
migrations.RunPython(change_owzt_to_global, reverse_code=migrations.RunPython.noop)
18+
]

openwisp_controller/config/tests/test_vpn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ def test_zerotier_auto_client(self, mock_requests, mock_subprocess):
12101210
for key in context_keys.keys():
12111211
context_keys[key] = '{{%s}}' % context_keys[key]
12121212
expected = template.backend_class.zerotier_auto_client(
1213-
name='ow_zt',
1213+
name='global',
12141214
networks=[{'id': vpn.network_id, 'ifname': f'owzt{vpn.network_id[-6:]}'}],
12151215
identity_secret=context_keys['secret'],
12161216
)

0 commit comments

Comments
 (0)