diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-03-14 07:11:53 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-03-14 07:11:53 +0000 |
commit | e0b2904ef83b5a082f3bae1756bc7633a659c8fc (patch) | |
tree | b4e0698ae9f50b8757530f2332cb1c40872d4a5c /src/util.rs | |
parent | d4cba41b5674e6ca1cbd5669aeb42d5f7d62e8bd (diff) | |
parent | b8119579a246727805a03c5a8e60fb44109410f6 (diff) | |
download | vmadm-e0b2904ef83b5a082f3bae1756bc7633a659c8fc.tar.gz |
Merge branch 'iso' into 'main'
fix: VMs can be restarted
Closes #17
See merge request larswirzenius/vmadm!19
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs new file mode 100644 index 0000000..9933f03 --- /dev/null +++ b/src/util.rs @@ -0,0 +1,15 @@ +//! Utilities. + +use std::net::TcpStream; + +const SSH_PORT: i32 = 22; + +// Wait for a virtual machine to have opened its SSH port. +pub fn wait_for_ssh(name: &str) { + let addr = format!("{}:{}", name, SSH_PORT); + loop { + if TcpStream::connect(&addr).is_ok() { + return; + } + } +} |