Skip to main content

Running

Struct Running 

Source
pub struct Running<'r> { /* private fields */ }
Expand description

A run of a project folder.

Implementations§

Source§

impl Running<'_>

Source

pub async fn service_endpoints( &self, opts: &RunOptions, ) -> Result<Vec<ServiceEndpoint>>

The service endpoints the deployment publishes (a Terraform module’s published output: { "web/site" = "192.0.2.10:8080" }), each where this computer reaches it: as the deployment gives it, or, when the run has a jump host (its ssh_jump value, user@host: the deployment’s network is internal to it), at a local forward through that host, kept open by this process (the module docs say how long). One whose forward doesn’t open says why, the others are given all the same. opts gives what the tools get. Emits nothing and never locks the run.

§Errors

As the deployment’s outputs can’t be read; input_invalid when the run’s ssh_jump isn’t user@host.

Source§

impl Running<'_>

Source

pub async fn graphical_console( &self, machine: &str, opts: &RunOptions, ) -> Result<Console>

machine’s graphical console (its screen), where its hypervisor keeps it: its protocol (VNC or RDP), where it answers (crate::Endpoint: a port of this computer’s loopback, or Proxmox’s VNC websocket) and the account and password that sign in. A console that answers only on the run’s own networks (a module’s Windows VM’s Remote Desktop) is reached through an SSH tunnel to the machine beside it the driver names: ssh -N -L 127.0.0.1:<free port>:<its address>:<its port>, signed in with the run’s key (its ssh_private_key_file, else the runner’s) and checked against the host key the run pinned the first time it met that machine. The returned Console owns the tunnel (Console::tunnel): keep it while the viewer shows the screen; dropping it ends the tunnel, and so does a down of the run. A console the hypervisor says listens anywhere but the loopback is refused, and so is one on the loopback that doesn’t answer. opts gives what the tools get (a Proxmox server’s address and credentials, as its provider reads them). Emits nothing and never locks the run; while an operation holds it, the hypervisor is asked all the same.

§Errors

machine_unknown for a machine the run doesn’t have; no_console when it has none (the error says why: a hypervisor whose screen opens only in its own app, VirtualBox without its extension pack…), isn’t running, its hypervisor doesn’t say where its console is or started it without one, or it doesn’t answer there; server_auth_failed when Proxmox refuses the run’s credentials; a tool’s own failure (tool_missing for a missing virsh, VBoxManage, curl, ssh or ssh-keyscan); tool_failed when the machine a tunnel goes through gives no SSH host key to pin.

Source

pub async fn native_console( &self, machine: &str, opts: &RunOptions, ) -> Result<NativeConsole>

What opens running VM machine in its hypervisor’s own app, beside the embedder’s viewer (crate::Status::native names the app): a program and its arguments, a macOS app and what it opens, or an https URL, best first, each argument checked; the embedder runs the first this computer has, never through a shell. Reads as Running::graphical_console does, and runs nothing but a read (Parallels’ prlctl, UTM’s utmctl, libvirt’s virsh).

§Errors

machine_unknown for a machine the run doesn’t have; no_console when its hypervisor has no app (QEMU, ESXi, a container), it isn’t running, or what names it can’t be handed to the app as it is.

Source§

impl<'r> Running<'r>

Source

pub fn sharing_elevation(self) -> Running<'r>

The same run, every operation of this handle sharing one elevation where its hypervisor needs one (Hyper-V on Windows): one administrator prompt for an up and the exec after it, say, instead of one per operation. The elevated session ends when the handle drops.

Source§

impl Running<'_>

Source

pub async fn status(&self) -> Result<Status>

The run as its tool reports it now, reconciled with its record: an operation of this process on the run leaves the machines as last read (not live).

§Errors

As the tool fails to answer; the store’s.

Source

pub async fn status_with(&self, opts: &RunOptions) -> Result<Status>

Running::status, its tools given opts’ values and secrets beside the recorded ones: what a read of the project’s own servers needs (a Proxmox VE module’s API token, for its VMs’ states on the server).

§Errors

As Running::status; server_auth_failed when a server refuses the credentials.

Source

pub async fn usage(&self, opts: &RunOptions) -> Result<Vec<MachineUsage>>

What each running machine of the run uses now, by name, as its engine samples it once: a Compose project’s containers (docker stats); none for a format whose tool reports no per-machine figure (Vagrant, Terraform). A machine not running has none. opts gives what the tools get. Emits nothing and never locks the run.

§Errors

As the tool fails: its engine doesn’t answer, or its answer can’t be read.

Source§

impl<'r> Running<'r>

Source

pub fn name(&self) -> &RunName

The run’s name.

Source

pub fn project(&self) -> &Project

The project it runs.

Source

pub async fn up( &self, opts: &RunOptions, events: &dyn Events, ) -> Result<Started>

Starts the run: makes and starts everything, and returns once the project says it’s ready.

§Errors

Fails, after its error event, as the run’s tool does (missing, too old, failing, out of time), with port_in_use for a host port taken, or as the run’s state refuses an up: already_running for a run that is ready and live (its tool says so now), before any tool acts. A run recorded ready whose machines are gone or stopped meanwhile starts again.

Source

pub async fn down(&self, opts: &RunOptions, events: &dyn Events) -> Result<()>

Removes everything the run made, the tunnels of its consoles ended first (whichever process holds them), and forgets its machines’ pinned SSH host keys.

§Errors

As Running::up’s tool failures.

Source

pub async fn park( &self, mode: Park, opts: &RunOptions, events: &dyn Events, ) -> Result<()>

Stops the machines and keeps them, as mode says.

§Errors

As the tool fails, or as the run’s state refuses a park.

Source

pub async fn resume(&self, opts: &RunOptions, events: &dyn Events) -> Result<()>

Starts the parked machines again.

§Errors

As the tool fails, or as the run’s state refuses a resume: nothing_to_resume for a run of which nothing is left (never started, brought down, or its parked machines removed meanwhile: its record then reads absent), before any tool acts.

Source

pub async fn update(&self, opts: &RunOptions, events: &dyn Events) -> Result<()>

Brings the running run to what the project’s files now say.

§Errors

As the tool fails; not_running, before any tool acts, when the run isn’t ready.

Source

pub async fn provision( &self, machine: Option<&str>, with: Option<&str>, opts: &RunOptions, events: &dyn Events, ) -> Result<()>

Runs the project’s set-up again (its provisioners), on machine or on every machine.

§Errors

As the tool fails; unsupported where the format has no set-up of its own to run again; not_running, before any tool acts, when nothing of the run runs. with, when given, runs only the provisioner of that name (a Vagrant project’s checks).

Source

pub async fn attach( &self, machine: &str, opts: &RunOptions, events: &dyn Events, ) -> Result<()>

Starts machine, one the project leaves down at up.

§Errors

As the tool fails; unsupported where the format has no such machine; not_running, before any tool acts, when nothing of the run runs.

Source

pub async fn retire( &self, machine: &str, opts: &RunOptions, events: &dyn Events, ) -> Result<()>

Removes machine from the running run.

§Errors

As the tool fails; not_running, before any tool acts, when the run isn’t ready.

Source

pub async fn package( &self, machine: &str, output: &Path, opts: &RunOptions, events: &dyn Events, ) -> Result<()>

Saves machine as a box file at output, which a later run boots from (vagrant box add it first): the machine is stopped first and kept, so the run reads failed after, until it is resumed or brought down.

§Errors

As the tool fails; unsupported where the format makes no box (Compose, Terraform); not_running, before any tool acts, when the run isn’t ready.

Source

pub async fn exec( &self, machine: &str, argv: &[String], opts: &RunOptions, events: &dyn Events, ) -> Result<ExecReport>

Runs argv in machine, with no terminal: what it said and how it ended. A command that runs and fails is a report, not an error.

§Errors

When the command can’t be run at all (the tool missing, the machine refused); not_running, before any tool acts, when nothing of the run runs.

Source

pub async fn console_command( &self, machine: &str, user: Option<&str>, ) -> Result<ShellCommand>

The command that opens an interactive console into machine, as user when given. A query: nothing runs.

§Errors

Where the format has no way in.

Auto Trait Implementations§

§

impl<'r> !Freeze for Running<'r>

§

impl<'r> !RefUnwindSafe for Running<'r>

§

impl<'r> !UnwindSafe for Running<'r>

§

impl<'r> Forget for Running<'r>

§

impl<'r> Move for Running<'r>

§

impl<'r> Send for Running<'r>

§

impl<'r> Sync for Running<'r>

§

impl<'r> Unpin for Running<'r>

§

impl<'r> UnsafeUnpin for Running<'r>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more