summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-09-15 17:12:25 +0200
committerMatthias Beyer <matthias.beyer@atos.net>2021-09-16 12:07:17 +0200
commited0c75f10afb02436eb43b29693941ec97795b46 (patch)
tree1b3664c42af705e1dfad11a70548be0f2313b313
parentf22cfc1e4a1938de54168e164aa074e7c57f9546 (diff)
Add fn to get number of running containers on endpoint
Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
-rw-r--r--src/endpoint/configured.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/endpoint/configured.rs b/src/endpoint/configured.rs
index 4a0e933..c6c4953 100644
--- a/src/endpoint/configured.rs
+++ b/src/endpoint/configured.rs
@@ -281,6 +281,24 @@ impl Endpoint {
})
}
+ pub async fn number_of_running_containers(&self) -> Result<usize> {
+ self.docker
+ .containers()
+ .list({
+ &shiplift::builder::ContainerListOptions::builder()
+ .all()
+ .build()
+ })
+ .await
+ .map_err(Error::from)
+ .map(|list| {
+ list.into_iter()
+ .inspect(|stat| trace!("stat = {:?}", stat))
+ .filter(|stat| stat.state == "running")
+ .count()
+ })
+ }
+
pub async fn has_container_with_id(&self, id: &str) -> Result<bool> {
self.container_stats()
.await?