Skip to content

Commit 2c54a38

Browse files
author
Ritwick DSouza
committed
[raspbian] Changed template format
1 parent 395dffb commit 2c54a38

11 files changed

Lines changed: 32 additions & 34 deletions

File tree

netjsonconfig/backends/raspbian/converters/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22

33

44
class RaspbianConverter(BaseConverter):
5-
def test_function(self):
6-
return 'Nothing'
5+
pass

netjsonconfig/backends/raspbian/raspbian.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class Raspbian(BaseBackend):
99
Raspbian Backend
1010
"""
1111
schema = schema
12-
env_path = 'netjsonconfig.backends.raspbian'
1312
converters = [
1413
converters.General,
1514
converters.Interfaces,

netjsonconfig/backends/raspbian/templates/hostapd.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% for i, j in data.items() %}
22
{% if i|string() == 'wireless' %}
33
{% for wireless in j %}
4-
config: /etc/hostapd/hostapd.conf
4+
# config: /etc/hostapd/hostapd.conf
55
interface={{ wireless.get('ifname') }}
66
driver=nl80211
77
hw_mode={{ wireless.get('hwmode')}}

netjsonconfig/backends/raspbian/templates/hostname.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{% if i|string() == 'general' %}
33
{% for general in j %}
44
{% if general.get('hostname') %}
5-
config: /etc/hostname
5+
# config: /etc/hostname
66
{{ general.get('hostname') }}
77

88
{% endif %}

netjsonconfig/backends/raspbian/templates/interfaces.jinja2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% for interface in j %}
44
{% if interface.get('iftype') == 'wireless' %}
55
{% if interface.get('mode') == 'adhoc' %}
6-
config: /etc/network/interfaces
6+
# config: /etc/network/interfaces
77
auto {{ interface.get('iftype') }}
88
iface {{ interface.get('iftype') }} inet static
99
address 172.128.1.1
@@ -13,7 +13,7 @@ iface {{ interface.get('iftype') }} inet static
1313
wireless-mode ad-hoc
1414
{% endif %}
1515
{% elif interface.get('iftype') in ['ethernet', 'bridge', 'loopback'] %}
16-
config: /etc/network/interfaces
16+
# config: /etc/network/interfaces
1717
auto {{ interface.get('ifname') }}
1818
{% if interface.get('address') != None %}
1919
{% for address in interface.get('address') %}

netjsonconfig/backends/raspbian/templates/ntp.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% for i, j in data.items() %}
22
{% if i|string() == 'ntp' %}
3-
config: /etc/ntp.conf
3+
# config: /etc/ntp.conf
44
{% for server in j %}
55
server {{ server }}
66
{% endfor %}

netjsonconfig/backends/raspbian/templates/resolv.jinja2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{% for i, j in data.items() %}
33
{% if i|string() in ['dns_servers', 'dns_search'] %}
44
{% if count == [1] %}
5-
config: /etc/resolv.conf
5+
# config: /etc/resolv.conf
66
{% if count.append(count.pop() + 1) %}{% endif %}
77
{% endif %}
88
{% endif %}

tests/raspbian/test_hostapd.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_wpa2_personal(self):
3737
]
3838
})
3939

40-
expected = '''config: /etc/hostapd/hostapd.conf
40+
expected = '''# config: /etc/hostapd/hostapd.conf
4141
interface=wlan0
4242
driver=nl80211
4343
hw_mode=g
@@ -84,7 +84,7 @@ def test_wpa_personal(self):
8484
]
8585
})
8686

87-
expected = '''config: /etc/hostapd/hostapd.conf
87+
expected = '''# config: /etc/hostapd/hostapd.conf
8888
interface=wlan0
8989
driver=nl80211
9090
hw_mode=g
@@ -199,7 +199,7 @@ def test_encryption_disabled(self):
199199
]
200200
})
201201

202-
expected = '''config: /etc/hostapd/hostapd.conf
202+
expected = '''# config: /etc/hostapd/hostapd.conf
203203
interface=wlan0
204204
driver=nl80211
205205
hw_mode=g
@@ -237,7 +237,7 @@ def test_no_encryption(self):
237237
]
238238
})
239239

240-
expected = '''config: /etc/hostapd/hostapd.conf
240+
expected = '''# config: /etc/hostapd/hostapd.conf
241241
interface=wlan0
242242
driver=nl80211
243243
hw_mode=g

tests/raspbian/test_interfaces.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_ipv4_static(self):
2424
]
2525
})
2626

27-
expected = '''config: /etc/network/interfaces
27+
expected = '''# config: /etc/network/interfaces
2828
auto eth0
2929
iface eth0 inet static
3030
address 10.0.0.1
@@ -51,7 +51,7 @@ def test_ipv6_static(self):
5151
]
5252
})
5353

54-
expected = '''config: /etc/network/interfaces
54+
expected = '''# config: /etc/network/interfaces
5555
auto eth0
5656
iface eth0 inet6 static
5757
address fe80::ba27:ebff:fe1c:5477
@@ -84,7 +84,7 @@ def test_multiple_static(self):
8484
]
8585
})
8686

87-
expected = '''config: /etc/network/interfaces
87+
expected = '''# config: /etc/network/interfaces
8888
auto eth0
8989
iface eth0 inet static
9090
address 10.0.0.1
@@ -112,7 +112,7 @@ def test_ipv4_dhcp(self):
112112
]
113113
})
114114

115-
expected = '''config: /etc/network/interfaces
115+
expected = '''# config: /etc/network/interfaces
116116
auto eth0
117117
iface eth0 inet dhcp
118118
@@ -135,7 +135,7 @@ def test_ipv6_dhcp(self):
135135
]
136136
})
137137

138-
expected = '''config: /etc/network/interfaces
138+
expected = '''# config: /etc/network/interfaces
139139
auto eth0
140140
iface eth0 inet6 dhcp
141141
@@ -163,7 +163,7 @@ def test_multiple_dhcp(self):
163163
]
164164
})
165165

166-
expected = '''config: /etc/network/interfaces
166+
expected = '''# config: /etc/network/interfaces
167167
auto eth0
168168
iface eth0 inet dhcp
169169
iface eth0 inet6 dhcp
@@ -202,7 +202,7 @@ def test_multiple_ip(self):
202202
]
203203
})
204204

205-
expected = '''config: /etc/network/interfaces
205+
expected = '''# config: /etc/network/interfaces
206206
auto eth0.1
207207
iface eth0.1 inet static
208208
address 192.168.1.1
@@ -234,7 +234,7 @@ def test_mtu(self):
234234
],
235235
})
236236

237-
expected = '''config: /etc/network/interfaces
237+
expected = '''# config: /etc/network/interfaces
238238
auto eth1
239239
iface eth1 inet dhcp
240240
pre-up /sbin/ifconfig $IFACE mtu 1500
@@ -259,7 +259,7 @@ def test_mac(self):
259259
],
260260
})
261261

262-
expected = '''config: /etc/network/interfaces
262+
expected = '''# config: /etc/network/interfaces
263263
auto eth1
264264
iface eth1 inet dhcp
265265
hwaddress 52:54:00:56:46:c0
@@ -296,7 +296,7 @@ def test_multiple_ip_and_dhcp(self):
296296
]
297297
})
298298

299-
expected = '''config: /etc/network/interfaces
299+
expected = '''# config: /etc/network/interfaces
300300
auto eth0
301301
iface eth0 inet dhcp
302302
iface eth0 inet static
@@ -329,13 +329,13 @@ def test_interface_with_resolv(self):
329329
"dns_search": ["netjson.org", "openwisp.org"],
330330
})
331331

332-
expected = '''config: /etc/network/interfaces
332+
expected = '''# config: /etc/network/interfaces
333333
auto eth0
334334
iface eth0 inet static
335335
address 192.168.1.1
336336
netmask 255.255.255.0
337337
338-
config: /etc/resolv.conf
338+
# config: /etc/resolv.conf
339339
nameserver 10.11.12.13
340340
nameserver 8.8.8.8
341341
search netjson.org
@@ -361,7 +361,7 @@ def test_loopback(self):
361361
]
362362
})
363363

364-
expected = '''config: /etc/network/interfaces
364+
expected = '''# config: /etc/network/interfaces
365365
auto lo
366366
iface lo inet static
367367
address 127.0.0.1
@@ -386,7 +386,7 @@ def test_adhoc_wireless(self):
386386
]
387387
})
388388

389-
expected = '''config: /etc/network/interfaces
389+
expected = '''# config: /etc/network/interfaces
390390
auto wireless
391391
iface wireless inet static
392392
address 172.128.1.1
@@ -413,7 +413,7 @@ def test_simple_bridge(self):
413413
]
414414
})
415415

416-
expected = '''config: /etc/network/interfaces
416+
expected = '''# config: /etc/network/interfaces
417417
auto br-lan
418418
bridge_ports eth0 eth1
419419
@@ -443,7 +443,7 @@ def test_complex_bridge(self):
443443
]
444444
})
445445

446-
expected = '''config: /etc/network/interfaces
446+
expected = '''# config: /etc/network/interfaces
447447
auto brwifi
448448
iface brwifi inet6 static
449449
address fe80::8029:23ff:fe7d:c214

tests/raspbian/test_resolv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def test_dns_server(self):
1414
],
1515
})
1616

17-
expected = '''config: /etc/resolv.conf
17+
expected = '''# config: /etc/resolv.conf
1818
nameserver 10.254.0.1
1919
nameserver 10.254.0.2
2020
'''
@@ -27,7 +27,7 @@ def test_dns_search(self):
2727
],
2828
})
2929

30-
expected = '''config: /etc/resolv.conf
30+
expected = '''# config: /etc/resolv.conf
3131
search domain.com
3232
'''
3333
self.assertEqual(o.render(), expected)
@@ -43,7 +43,7 @@ def test_dns_server_and_dns_search(self):
4343
],
4444
})
4545

46-
expected = '''config: /etc/resolv.conf
46+
expected = '''# config: /etc/resolv.conf
4747
nameserver 10.11.12.13
4848
nameserver 8.8.8.8
4949
search netjson.org

0 commit comments

Comments
 (0)