a start a configure-wifi ui

This commit is contained in:
Michael Hudson-Doyle 2016-09-05 12:03:06 +12:00
parent 92267db86b
commit bf3384596e
5 changed files with 51 additions and 6 deletions

View File

@ -29,7 +29,8 @@ from subiquitycore.ui.views import (NetworkView,
NetworkSetDefaultRouteView,
NetworkBondInterfacesView,
NetworkConfigureInterfaceView,
NetworkConfigureIPv4InterfaceView)
NetworkConfigureIPv4InterfaceView,
NetworkConfigureWLANInterfaceView)
from subiquitycore.ui.views.network import ApplyingConfigWidget
from subiquitycore.ui.dummy import DummyView
from subiquitycore.controller import BaseController
@ -275,9 +276,10 @@ class NetworkController(BaseController):
def network_configure_interface(self, iface):
self.ui.set_header("Network interface {}".format(iface))
self.ui.set_body(NetworkConfigureInterfaceView(self.model,
self.signal,
iface))
if self.model.devices[iface].iftype == 'wlan':
self.ui.set_body(NetworkConfigureWLANInterfaceView(self.model, self.signal, iface))
else:
self.ui.set_body(NetworkConfigureInterfaceView(self.model, self.signal, iface))
def network_configure_ipv4_interface(self, iface):
self.model.prev_signal = ('Back to configure interface menu',

View File

@ -43,6 +43,7 @@ class Networkdev():
self.search_domains = []
self.nameservers = []
self.gateway = None
self.essid = None
def configure(self, probe_info=None):
log.debug('Configuring iface {}'.format(self.ifname))
@ -53,6 +54,9 @@ class Networkdev():
def configure_from_info(self):
log.debug('configuring netdev from info source')
if self.iftype == 'wlan':
self.essid = self.probe_info.raw['essid']
ip_info = self.probe_info.ip
sources = ip_info.get('sources', None)
@ -113,6 +117,9 @@ class Networkdev():
if self.iftype == 'bond':
result[self.ifname]['interfaces'] = self.probe_info.bond['slaves']
if self.iftype == 'wlan':
pass
return result
@property
@ -640,15 +647,20 @@ class NetworkModel(BaseModel):
}
ethernets = {}
bonds = {}
wifis = {}
for iface in self.devices.values():
if iface.iftype == 'eth':
ethernets.update(iface.render())
if iface.iftype == 'bond':
bonds.update(iface.render())
if iface.iftype == 'wlan':
wifis.update(iface.render())
if any(ethernets):
config['network']['ethernets'] = ethernets
if any(bonds):
config['network']['bonds'] = bonds
if any(wifis):
config['network']['wifis'] = wifis
routes = self.get_default_route()
nw_routes = []

View File

@ -15,7 +15,7 @@
from .network import NetworkView # NOQA
from .network_default_route import NetworkSetDefaultRouteView # NOQA
from .network_configure_interface import NetworkConfigureInterfaceView # NOQA
from .network_configure_interface import NetworkConfigureInterfaceView, NetworkConfigureWLANInterfaceView # NOQA
from .network_configure_ipv4_interface import NetworkConfigureIPv4InterfaceView # NOQA
from .network_bond_interfaces import NetworkBondInterfacesView # NOQA
from .welcome import CoreWelcomeView as WelcomeView # NOQA

View File

@ -172,6 +172,12 @@ class NetworkView(BaseView):
col_1.append(Text(""))
col_2.append(Color.info_primary(Text(template)))
if interface.iftype == 'wlan':
if interface.essid is not None:
col_2.append(Text("Associated to '" + interface.essid + "'"))
else:
col_2.append(Text("Not associated."))
# Other device info (MAC, vendor/model, speed)
info = self.model.get_iface_info(iface)
hwaddr = self.model.get_hw_addr(iface)

View File

@ -32,6 +32,9 @@ class NetworkConfigureInterfaceView(BaseView):
self.ipv4_method = Pile(self._build_ipv4_method_buttons())
self.ipv6_info = Pile(self._build_gateway_ipv6_info())
self.ipv6_method = Pile(self._build_ipv6_method_buttons())
super().__init__(ListBox(self._build_body()))
def _build_body(self):
body = [
Padding.center_79(self.ipv4_info),
Padding.center_79(self.ipv4_method),
@ -42,7 +45,7 @@ class NetworkConfigureInterfaceView(BaseView):
Padding.line_break(""),
Padding.fixed_10(self._build_buttons())
]
super().__init__(ListBox(body))
return body
def _build_gateway_ipv4_info(self):
addresses = self.iface_obj.ipv4_addresses
@ -184,3 +187,25 @@ class NetworkConfigureInterfaceView(BaseView):
def done(self, result):
self.signal.prev_signal()
class NetworkConfigureWLANInterfaceView(NetworkConfigureInterfaceView):
def __init__(self, model, signal, iface):
self.wifi_info = Pile(self._build_wifi_info())
self.wifi_method = Pile(self._build_wifi_config())
super().__init__(model, signal, iface)
def _build_wifi_info(self):
return [Text("WIFI")]
def _build_wifi_config(self):
return [Text("[config]")]
def _build_body(self):
body = [
Padding.center_79(self.wifi_info),
Padding.center_79(self.wifi_method),
Padding.line_break(""),
]
body.extend(super()._build_body())
return body