summaryrefslogtreecommitdiff
path: root/src/util.rs
blob: f3e104b7bd0316510e045b96fd270423d6c07611 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Utilities.

use log::debug;
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) {
    debug!("waiting for {} to respond to SSH", name);
    let addr = format!("{}:{}", name, SSH_PORT);
    loop {
        if TcpStream::connect(&addr).is_ok() {
            return;
        }
    }
}