Module: VagrantPlugins::OrbStack::Util::SSHReadinessChecker

Defined in:
lib/vagrant-orbstack/util/ssh_readiness_checker.rb

Overview

Utility module for waiting until SSH becomes available on an OrbStack machine

This module provides a polling mechanism to check if an OrbStack machine is ready for SSH connections. It repeatedly queries the machine status until the machine reports as 'running', indicating SSH is available.

Examples:

Wait for SSH on a newly created machine

SSHReadinessChecker.wait_for_ready('my-machine', ui: ui)

Handle timeout gracefully

begin
  SSHReadinessChecker.wait_for_ready('my-machine', ui: ui)
rescue VagrantPlugins::OrbStack::SSHNotReady => e
  ui.error("SSH not ready: #{e.message}")
end

Constant Summary collapse

MAX_WAIT_TIME =

Maximum time to wait for SSH to become ready (in seconds)

Returns:

  • (Integer)

    Timeout in seconds

120
POLL_INTERVAL =

Interval between status polls (in seconds)

Returns:

  • (Integer)

    Poll interval in seconds

2

Class Method Summary collapse

Class Method Details

.wait_for_ready(machine_name, ui:) ⇒ Boolean

Wait for SSH to become available on a machine.

Polls the machine status every POLL_INTERVAL seconds until the machine reports 'running' status, or until MAX_WAIT_TIME is exceeded. Displays progress messages via the provided UI object.

rubocop:disable Naming/MethodParameterName

Examples:

Wait for SSH

SSHReadinessChecker.wait_for_ready('ubuntu-dev', ui: machine.ui)
# => true

Parameters:

  • machine_name (String)

    The name of the machine to check

  • ui (Vagrant::UI::Interface)

    UI object for displaying progress messages

Returns:

  • (Boolean)

    true when SSH is ready

Raises:



55
56
57
58
59
60
61
# File 'lib/vagrant-orbstack/util/ssh_readiness_checker.rb', line 55

def self.wait_for_ready(machine_name, ui:)
  # rubocop:enable Naming/MethodParameterName
  ui.info("Waiting for SSH to become available on #{machine_name}...")

  poll_until_ready(machine_name, ui) ||
    raise_timeout_error(machine_name)
end