start on configure interface view
This commit is contained in:
parent
724a99ac1a
commit
959743aded
|
@ -15,10 +15,12 @@
|
|||
|
||||
import logging
|
||||
|
||||
import yaml
|
||||
|
||||
from subiquitycore.controller import BaseController
|
||||
|
||||
from console_conf.models import NetworkModel
|
||||
from console_conf.ui.views import NetworkView
|
||||
from console_conf.ui.views import NetworkView, NetworkConfigureInterfaceView
|
||||
|
||||
log = logging.getLogger("subiquitycore.controller.network")
|
||||
|
||||
|
@ -39,4 +41,10 @@ class NetworkController(BaseController):
|
|||
self.ui.set_body(NetworkView(self.model, self.signal))
|
||||
|
||||
def network_finish(self, config):
|
||||
log.debug("network config: \n%s", yaml.dump(config))
|
||||
self.signal.emit_signal('menu:identity:main')
|
||||
|
||||
def network_configure_interface(self, interface):
|
||||
self.ui.set_header("Network interface {}".format(interface))
|
||||
self.ui.set_body(NetworkConfigureInterfaceView(
|
||||
self.model, self.signal, interface))
|
||||
|
|
|
@ -34,9 +34,9 @@ class NetworkModel(BaseModel):
|
|||
('Network finish',
|
||||
'network:finish',
|
||||
'network_finish'),
|
||||
## ('Network configure interface',
|
||||
## base_signal + ':configure-interface',
|
||||
## 'network_configure_interface'),
|
||||
('Network configure interface',
|
||||
base_signal + ':configure-interface',
|
||||
'network_configure_interface'),
|
||||
## ('Network configure ipv4 interface',
|
||||
## base_signal + ':configure-ipv4-interface',
|
||||
## 'network_configure_ipv4_interface')
|
||||
|
|
|
@ -19,3 +19,4 @@ from .identity import IdentityView # NOQA
|
|||
from .login import LoginView # NOQA
|
||||
from .welcome import WelcomeView # NOQA
|
||||
from .network import NetworkView # NOQA
|
||||
from .network_configure_interface import NetworkConfigureInterfaceView # NOQA
|
||||
|
|
|
@ -116,5 +116,5 @@ class NetworkView(BaseView):
|
|||
self.model.reset()
|
||||
self.signal.prev_signal()
|
||||
|
||||
def on_net_dev_press(self, button):
|
||||
pass
|
||||
def on_net_dev_press(self, result):
|
||||
self.signal.emit_signal('menu:network:main:configure-interface', result.label)
|
||||
|
|
|
@ -0,0 +1,96 @@
|
|||
# Copyright 2015 Canonical, Ltd.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from urwid import Text, Pile, ListBox
|
||||
from subiquitycore.view import BaseView
|
||||
from subiquitycore.ui.buttons import done_btn, menu_btn
|
||||
from subiquitycore.ui.utils import Color, Padding
|
||||
import logging
|
||||
|
||||
log = logging.getLogger('subiquitycore.network.network_configure_interface')
|
||||
|
||||
|
||||
class NetworkConfigureInterfaceView(BaseView):
|
||||
def __init__(self, model, signal, iface):
|
||||
self.model = model
|
||||
self.signal = signal
|
||||
self.iface = iface
|
||||
body = [
|
||||
## Padding.center_79(self._build_gateway_ipv4_info()),
|
||||
## Padding.center_79(self._build_manual_ipv4_button()),
|
||||
## Padding.line_break(""),
|
||||
## Padding.line_break(""),
|
||||
## Padding.center_79(self._build_gateway_ipv6_info()),
|
||||
## Padding.center_79(self._build_manual_ipv6_button()),
|
||||
## Padding.line_break(""),
|
||||
Padding.fixed_10(self._build_buttons())
|
||||
]
|
||||
super().__init__(ListBox(body))
|
||||
|
||||
def _build_gateway_ipv4_info(self):
|
||||
header = ("IPv4 not configured")
|
||||
gw_info = None
|
||||
ip = self.iface_obj.ip
|
||||
method = self.iface_obj.ip_method
|
||||
provider = self.iface_obj.ip_provider
|
||||
|
||||
if not (None in [ip, provider, method]):
|
||||
if method in ['dhcp']:
|
||||
header = ("Will use DHCP for IPv4:")
|
||||
else:
|
||||
header = ("Will use static for IPv4:")
|
||||
gw_info = (str(ip) + (" provided by ") + method +
|
||||
(" from ") + provider)
|
||||
|
||||
p = [Text(header)]
|
||||
if gw_info:
|
||||
p.append(Text(gw_info))
|
||||
|
||||
return Pile(p)
|
||||
|
||||
def _build_gateway_ipv6_info(self):
|
||||
header = ("IPv6 not configured")
|
||||
gw_info = None
|
||||
|
||||
p = [Text(header)]
|
||||
if gw_info:
|
||||
p.append(Text(gw_info))
|
||||
|
||||
return Pile(p)
|
||||
|
||||
def _build_manual_ipv4_button(self):
|
||||
btn = menu_btn(label="Switch to manual IPv4 configuration",
|
||||
on_press=self.show_ipv4_configuration)
|
||||
return Pile([Color.menu_button(btn, focus_map="menu_button focus")])
|
||||
|
||||
def _build_manual_ipv6_button(self):
|
||||
text = ("Switch to manual IPv6 configuration")
|
||||
# FIXME: ipv6 testing
|
||||
# btn = menu_btn(label=text,
|
||||
# on_press=self.show_ipv6_configuration)
|
||||
# mb = Color.menu_button(btn, focus_map="menu_button focus")
|
||||
mb = Color.info_minor(Text(" " + text))
|
||||
return Pile([mb])
|
||||
|
||||
def _build_buttons(self):
|
||||
done = done_btn(on_press=self.done)
|
||||
|
||||
buttons = [
|
||||
Color.button(done, focus_map='button focus'),
|
||||
]
|
||||
return Pile(buttons)
|
||||
|
||||
def done(self, result):
|
||||
self.signal.prev_signal()
|
Loading…
Reference in New Issue