Skip to content

Commit 8e4b9d9

Browse files
committed
Only display VMs with a running status (in the Vms plugin)
1 parent 6fa969a commit 8e4b9d9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

glances/plugins/vms/engines/multipass.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ def update(self, all_tag) -> Tuple[Dict, List[Dict]]:
9898

9999
# Get the stats from the system
100100
version_stats = self.update_version()
101-
102-
# TODO: manage all_tag option
103101
info_stats = self.update_info()
104-
105102
returned_stats = []
106103
for k, v in info_stats.items():
107-
returned_stats.append(self.generate_stats(k, v))
104+
# Only display when VM in on 'running' states
105+
# See states list here: https://multipass.run/docs/instance-states
106+
if self._want_display(v, 'state', ['Running', 'Starting', 'Restarting']):
107+
returned_stats.append(self.generate_stats(k, v))
108108

109109
return version_stats, returned_stats
110110

@@ -113,6 +113,9 @@ def key(self) -> str:
113113
"""Return the key of the list."""
114114
return 'name'
115115

116+
def _want_display(self, vm_stats, key, values):
117+
return vm_stats.get(key).lower() in [v.lower() for v in values]
118+
116119
def generate_stats(self, vm_name, vm_stats) -> Dict[str, Any]:
117120
# Init the stats for the current vm
118121
return {

0 commit comments

Comments
 (0)