Deal with aborted status in Vagrant

This commit is contained in:
Roey Darwish Dror
2020-06-13 07:40:03 +03:00
parent bf5482caea
commit 73a66e78b0

View File

@@ -15,13 +15,14 @@ enum BoxStatus {
PowerOff, PowerOff,
Running, Running,
Saved, Saved,
Aborted,
} }
impl BoxStatus { impl BoxStatus {
fn powered_on(self) -> bool { fn powered_on(self) -> bool {
match self { match self {
BoxStatus::PowerOff | BoxStatus::Saved => false,
BoxStatus::Running => true, BoxStatus::Running => true,
_ => false,
} }
} }
} }
@@ -95,9 +96,9 @@ impl<'a> TemporaryPowerOn<'a> {
ctx: &'a ExecutionContext<'a>, ctx: &'a ExecutionContext<'a>,
) -> Result<Self> { ) -> Result<Self> {
let subcommand = match status { let subcommand = match status {
BoxStatus::PowerOff => "up", BoxStatus::PowerOff | BoxStatus::Aborted => "up",
BoxStatus::Saved => "resume", BoxStatus::Saved => "resume",
_ => unreachable!(), BoxStatus::Running => unreachable!(),
}; };
println!("Powering on {}", vagrant_box); println!("Powering on {}", vagrant_box);
@@ -118,9 +119,9 @@ impl<'a> TemporaryPowerOn<'a> {
impl<'a> Drop for TemporaryPowerOn<'a> { impl<'a> Drop for TemporaryPowerOn<'a> {
fn drop(&mut self) { fn drop(&mut self) {
let subcommand = match self.status { let subcommand = match self.status {
BoxStatus::PowerOff => "halt", BoxStatus::PowerOff | BoxStatus::Aborted => "halt",
BoxStatus::Saved => "suspend", BoxStatus::Saved => "suspend",
_ => unreachable!(), BoxStatus::Running => unreachable!(),
}; };
println!("Powering off {}", self.vagrant_box); println!("Powering off {}", self.vagrant_box);