Skip to content

Commit

Permalink
refactor: make user network mode available already in shell state
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoisel committed Jan 1, 2025
1 parent 7b30e7a commit 2daf33e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
9 changes: 5 additions & 4 deletions util/strategy/qemu_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,17 @@ def transition(self, state: Status | str, *, step: Step) -> None:
self.qemu.on()
self.target.activate(self.qemu)
self.target.activate(self.shell)
assert self.shell

elif state == Status.ssh:
self.transition(Status.shell)

assert self.shell
if uci.get(self.shell, "network.lan.proto") != "dhcp":
uci.set(self.shell, "network.lan.proto", "dhcp")
uci.commit(self.shell, "network")
service.restart(self.shell, "network", wait=1)

elif state == Status.ssh:
self.transition(Status.shell)

assert self.shell
self.update_network_service()

self.status = state
9 changes: 5 additions & 4 deletions util/strategy/qemu_stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ def transition(self, state: Status | str, *, step: Step) -> None:
# check if target is running
self.target.activate(self.qemu)
self.target.activate(self.shell)
assert self.shell

elif state == Status.ssh:
self.transition(Status.shell)

assert self.shell
if uci.get(self.shell, "network.lan.proto") != "dhcp":
uci.set(self.shell, "network.lan.proto", "dhcp")
uci.commit(self.shell, "network")
service.restart(self.shell, "network", wait=1)

elif state == Status.ssh:
self.transition(Status.shell)

assert self.shell
self.update_network_service()
else:
raise StrategyError(f"no transition found from {self.status} to {status}")
Expand Down

0 comments on commit 2daf33e

Please sign in to comment.