From fcd275652e9ffad328e69b96451dff79eb31a1d6 Mon Sep 17 00:00:00 2001 From: crschnick Date: Thu, 2 Apr 2026 22:14:00 +0000 Subject: [PATCH] Adjust incus/lxd fixues --- .../ext/system/incus/IncusContainerStore.java | 21 +++++++++---------- .../incus/IncusContainerStoreProvider.java | 7 ++++--- .../ext/system/lxd/LxdContainerStore.java | 3 +++ .../system/lxd/LxdContainerStoreProvider.java | 7 ++++--- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStore.java b/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStore.java index 7143fe5b6..3bbbaa82d 100644 --- a/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStore.java +++ b/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStore.java @@ -97,8 +97,7 @@ public class IncusContainerStore @Override public ShellControl control(ShellControl parent) throws Exception { - refreshContainerState( - getInstall().getStore().getHost().getStore().getOrStartSession()); + refreshContainerState(); var user = identity != null ? identity.unwrap().getUsername().retrieveUsername() : null; var sc = view(parent).exec(containerName, user, () -> { @@ -136,9 +135,9 @@ public class IncusContainerStore }; } - private void refreshContainerState(ShellControl sc) throws Exception { + private void refreshContainerState() throws Exception { var state = getState(); - var view = view(sc); + var view = view(); var displayState = view.queryContainerState(containerName); if (displayState.isEmpty()) { return; @@ -156,27 +155,27 @@ public class IncusContainerStore @Override public void start() throws Exception { - var sc = getInstall().getStore().getHost().getStore().getOrStartSession(); var view = view(); view.start(containerName); - refreshContainerState(sc); + // Give the network some time to initialize so the state + // gets updated to include any IP address + ThreadHelper.sleep(500); + refreshContainerState(); } @Override public void stop() throws Exception { stopSessionIfNeeded(); - var sc = getInstall().getStore().getHost().getStore().getOrStartSession(); var view = view(); view.stop(containerName); - refreshContainerState(sc); + refreshContainerState(); } @Override public void pause() throws Exception { - var sc = getInstall().getStore().getHost().getStore().getOrStartSession(); var view = view(); view.pause(containerName); - refreshContainerState(sc); + refreshContainerState(); } @Override @@ -192,7 +191,7 @@ public class IncusContainerStore @Override public void refreshHostAddressOrThrow() throws Exception { - refreshContainerState(getInstall().getStore().getHost().getStore().getOrStartSession()); + refreshContainerState(); } @Override diff --git a/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStoreProvider.java b/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStoreProvider.java index 3e81f27de..28f8ed692 100644 --- a/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStoreProvider.java +++ b/ext/system/src/main/java/io/xpipe/ext/system/incus/IncusContainerStoreProvider.java @@ -37,11 +37,12 @@ public class IncusContainerStoreProvider implements ShellStoreProvider { @Override public ObservableValue informationString(StoreSection section) { - var c = (NetworkContainerStoreState) section.getWrapper().getPersistentState().getValue(); - var missing = c.getShellMissing() != null && c.getShellMissing() ? "No shell available" : null; return StoreStateFormat.shellStore( section, - (ContainerStoreState s) -> new String[] {missing, DataStoreFormatter.capitalize(s.getContainerState()), c.getIpv4()}, + (NetworkContainerStoreState s) -> { + var missing = s.getShellMissing() != null && s.getShellMissing() ? "No shell available" : null; + return new String[] {missing, DataStoreFormatter.capitalize(s.getContainerState()), s.getIpv4()}; + }, null); } diff --git a/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStore.java b/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStore.java index 076fc4ae8..d55eda81a 100644 --- a/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStore.java +++ b/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStore.java @@ -157,6 +157,9 @@ public class LxdContainerStore public void start() throws Exception { var view = view(); view.start(containerName); + // Give the network some time to initialize so the state + // gets updated to include any IP address + ThreadHelper.sleep(500); refreshContainerState(); } diff --git a/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStoreProvider.java b/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStoreProvider.java index be12a7001..99370b1e2 100644 --- a/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStoreProvider.java +++ b/ext/system/src/main/java/io/xpipe/ext/system/lxd/LxdContainerStoreProvider.java @@ -37,11 +37,12 @@ public class LxdContainerStoreProvider implements ShellStoreProvider { @Override public ObservableValue informationString(StoreSection section) { - var c = (NetworkContainerStoreState) section.getWrapper().getPersistentState().getValue(); - var missing = c.getShellMissing() != null && c.getShellMissing() ? "No shell available" : null; return StoreStateFormat.shellStore( section, - (ContainerStoreState s) -> new String[] {missing, DataStoreFormatter.capitalize(s.getContainerState()), c.getIpv4()}, + (NetworkContainerStoreState s) -> { + var missing = s.getShellMissing() != null && s.getShellMissing() ? "No shell available" : null; + return new String[] {missing, DataStoreFormatter.capitalize(s.getContainerState()), s.getIpv4()}; + }, null); }