hacking that might be enough to let you turn dhcp on for an interface
This commit is contained in:
parent
2857cc90a3
commit
12c0947bad
|
@ -14,10 +14,13 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
import netifaces
|
||||
import yaml
|
||||
|
||||
from subiquitycore.controller import BaseController
|
||||
from subiquitycore.utils import run_command
|
||||
|
||||
from console_conf.models import NetworkModel
|
||||
from console_conf.ui.views import NetworkView, NetworkConfigureInterfaceView
|
||||
|
@ -42,9 +45,18 @@ class NetworkController(BaseController):
|
|||
|
||||
def network_finish(self, config):
|
||||
log.debug("network config: \n%s", yaml.dump(config))
|
||||
#self.ui.frame.body =
|
||||
if self.opts.dry_run:
|
||||
pass
|
||||
else:
|
||||
with open('/etc/netplan/01-console-conf.yaml', 'w') as w:
|
||||
w.write(yaml.dump(config))
|
||||
run_command(['systemctl', 'restart', 'systemd-networkd'])
|
||||
while 'default' not in netifaces.gateways():
|
||||
time.sleep(0.1)
|
||||
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))
|
||||
self.model, self.signal, self.model.config.ethernets[interface]))
|
||||
|
|
|
@ -86,12 +86,12 @@ class NetworkView(BaseView):
|
|||
t = addr.with_prefixlen
|
||||
if addr.version == 4:
|
||||
if iface.dhcp4:
|
||||
t += " (dhcp)"
|
||||
t += " (from dhcp4)"
|
||||
else:
|
||||
t += " (static)"
|
||||
elif addr.version == 6:
|
||||
if iface.dhcp6:
|
||||
t += " (dhcp)"
|
||||
t += " (from dhcp6)"
|
||||
else:
|
||||
t += " (static)"
|
||||
col_2.append(Text(t))
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
# 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 urwid import Text, Pile, ListBox, CheckBox
|
||||
from subiquitycore.view import BaseView
|
||||
from subiquitycore.ui.buttons import done_btn, menu_btn
|
||||
from subiquitycore.ui.buttons import done_btn, menu_btn, cancel_btn
|
||||
from subiquitycore.ui.utils import Color, Padding
|
||||
import logging
|
||||
|
||||
|
@ -27,7 +27,11 @@ class NetworkConfigureInterfaceView(BaseView):
|
|||
self.model = model
|
||||
self.signal = signal
|
||||
self.iface = iface
|
||||
self.dhcp4_box = CheckBox("Use DHCP for IPv4", state=iface.dhcp4)
|
||||
self.dhcp6_box = CheckBox("Use DHCP for IPv6", state=iface.dhcp6)
|
||||
body = [
|
||||
Padding.center_79(self.dhcp4_box),
|
||||
Padding.center_79(self.dhcp6_box),
|
||||
## Padding.center_79(self._build_gateway_ipv4_info()),
|
||||
## Padding.center_79(self._build_manual_ipv4_button()),
|
||||
## Padding.line_break(""),
|
||||
|
@ -86,11 +90,18 @@ class NetworkConfigureInterfaceView(BaseView):
|
|||
|
||||
def _build_buttons(self):
|
||||
done = done_btn(on_press=self.done)
|
||||
cancel = cancel_btn(on_press=self.cancel)
|
||||
|
||||
buttons = [
|
||||
Color.button(done, focus_map='button focus'),
|
||||
Color.button(cancel),
|
||||
]
|
||||
return Pile(buttons)
|
||||
|
||||
def done(self, result):
|
||||
self.iface.dhcp4 = self.dhcp4_box.get_state()
|
||||
self.iface.dhcp6 = self.dhcp6_box.get_state()
|
||||
self.signal.prev_signal()
|
||||
|
||||
def cancel(self, result):
|
||||
self.signal.prev_signal()
|
||||
|
|
Loading…
Reference in New Issue