Skip to content

Commit

Permalink
[raspbian] Added support for manual mode in interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Ritwick DSouza committed Jul 19, 2017
1 parent 7adfcfb commit 62fc58d
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
13 changes: 6 additions & 7 deletions netjsonconfig/backends/raspbian/templates/interfaces.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{% if i|string() == 'interfaces' %}
{% for interface in j %}
{% if interface.get('iftype') in ['ethernet', 'bridge', 'loopback', 'wireless'] %}
{% if interface.get('address') != None %}
# config: /etc/network/interfaces
{% if interface.get('address') != None %}

auto {{ interface.get('ifname') }}
{% for address in interface.get('address') %}
Expand Down Expand Up @@ -67,17 +67,16 @@
{% endif%}
{% endfor %}
{% else %}
{% if interface.get('iftype') == 'bridge' %}
# config: /etc/network/interfaces

auto {{ interface.get('ifname') }}
{% if interface.get('iftype') == 'wireless' and interface.get('mode') != 'adhoc' %}
iface {{ interface.get('ifname') }} inet manual
{% endif %}
{% if interface.get('iftype') == 'bridge' %}
bridge_ports {{ interface.get('bridge_members')[0] }} {{ interface.get('bridge_members')[1] }}
{% endif %}
{% if interface.get('mode') == 'adhoc' %}
# config: /etc/network/interfaces

auto {{ interface.get('iftype') }}
iface {{ interface.get('iftype') }} inet static
iface {{ interface.get('ifname') }} inet static
address 172.128.1.1
netmask 255.255.255.0
wireless-channel 1
Expand Down
16 changes: 16 additions & 0 deletions tests/raspbian/test_hostapd.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def test_wpa2_personal(self):
wpa_key_mgmt=WPA-PSK
wpa_passphrase=passphrase012345
wpa_pairwise=TKIP CCMP
# config: /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
'''
self.assertEqual(o.render(), expected)
Expand Down Expand Up @@ -97,6 +101,10 @@ def test_wpa_personal(self):
wpa=1
wpa_key_mgmt=WPA-PSK
wpa_passphrase=passphrase012345
# config: /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
'''
self.assertEqual(o.render(), expected)
Expand Down Expand Up @@ -209,6 +217,10 @@ def test_encryption_disabled(self):
channel=3
ieee80211n=1
ssid=MyNetwork
# config: /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
'''
self.assertEqual(o.render(), expected)
Expand Down Expand Up @@ -248,6 +260,10 @@ def test_no_encryption(self):
channel=3
ieee80211n=1
ssid=open
# config: /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
'''
self.assertEqual(o.render(), expected)
Expand Down
4 changes: 2 additions & 2 deletions tests/raspbian/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,8 +401,8 @@ def test_adhoc_wireless(self):

expected = '''# config: /etc/network/interfaces
auto wireless
iface wireless inet static
auto wlan0
iface wlan0 inet static
address 172.128.1.1
netmask 255.255.255.0
wireless-channel 1
Expand Down
24 changes: 24 additions & 0 deletions tests/raspbian/test_radios.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def test_radio_multi(self):
channel=11
ieee80211n=1
ssid=myWiFi
# config: /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
'''
self.assertEqual(o.render(), expected)
Expand Down Expand Up @@ -89,6 +93,10 @@ def test_radio_n_24ghz(self):
channel=3
ieee80211n=1
ssid=myWiFi
# config: /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
'''
self.assertEqual(o.render(), expected)
Expand Down Expand Up @@ -127,6 +135,10 @@ def test_radio_n_5ghz(self):
channel=36
ieee80211n=1
ssid=myWiFi
# config: /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
'''
self.assertEqual(o.render(), expected)
Expand Down Expand Up @@ -164,6 +176,10 @@ def test_radio_ac(self):
channel=132
ieee80211ac=1
ssid=myWiFi
# config: /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
'''
self.assertEqual(o.render(), expected)
Expand Down Expand Up @@ -200,6 +216,10 @@ def test_radio_a(self):
hw_mode=a
channel=0
ssid=myWiFi
# config: /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
'''
self.assertEqual(o.render(), expected)
Expand Down Expand Up @@ -236,6 +256,10 @@ def test_radio_g(self):
hw_mode=g
channel=0
ssid=myWiFi
# config: /etc/network/interfaces
auto wlan0
iface wlan0 inet manual
'''
self.assertEqual(o.render(), expected)

0 comments on commit 62fc58d

Please sign in to comment.