Bsdkrun.Networks (bsdkrun_ex v0.1.0)

Copy Markdown View Source

Global-network operations: opt machines into a shared subnet so they get distinct IPs and reach each other by IP and by name (docker-compose style).

All functions return {:ok, value} or {:error, %Bsdkrun.Error{}}.

Summary

Functions

Join or switch a machine (by id or name) to a network. Applies on next start.

Create a global network (starts its shared switch).

Detach a machine from its network. Applies on its next start.

List global networks and their member counts.

The machines currently attached to network (running or stopped).

Remove one or more networks. force: true allows removal with running members.

Refresh members' /etc/hosts with the current membership so peers resolve by name (notably NetBSD), without restarting members.

Functions

connect(machine, network)

@spec connect(String.t(), String.t()) :: :ok | {:error, Bsdkrun.Error.t()}

Join or switch a machine (by id or name) to a network. Applies on next start.

create(name)

@spec create(String.t()) :: :ok | {:error, Bsdkrun.Error.t()}

Create a global network (starts its shared switch).

disconnect(machine)

@spec disconnect(String.t()) :: :ok | {:error, Bsdkrun.Error.t()}

Detach a machine from its network. Applies on its next start.

list()

@spec list() :: {:ok, [Bsdkrun.Types.NetworkInfo.t()]} | {:error, Bsdkrun.Error.t()}

List global networks and their member counts.

members(network)

@spec members(String.t()) ::
  {:ok, [Bsdkrun.Types.SandboxInfo.t()]} | {:error, Bsdkrun.Error.t()}

The machines currently attached to network (running or stopped).

remove(names, opts \\ [])

@spec remove(
  String.t() | [String.t()],
  keyword()
) :: :ok | {:error, Bsdkrun.Error.t()}

Remove one or more networks. force: true allows removal with running members.

sync(network)

@spec sync(String.t()) :: :ok | {:error, Bsdkrun.Error.t()}

Refresh members' /etc/hosts with the current membership so peers resolve by name (notably NetBSD), without restarting members.