diff --git a/features/cli/resume.feature b/features/cli/resume.feature new file mode 100644 index 0000000..ce9f429 --- /dev/null +++ b/features/cli/resume.feature @@ -0,0 +1,17 @@ +Feature: Resume a VM or VMs that were previously stopped + + Scenario: Resume without stopped Blimps + Given I have the Blimpfile: + """ + Blimpy.fleet do |f| + f.add(:aws) do |host| + host.name = 'Cucumber Host' + end + end + """ + When I run `blimpy resume` + Then the exit status should be 1 + And the output should contain: + """ + No fleet running right now, perhaps you should `start` one. + """ diff --git a/lib/blimpy/cli.rb b/lib/blimpy/cli.rb index 7bee370..eed35b8 100644 --- a/lib/blimpy/cli.rb +++ b/lib/blimpy/cli.rb @@ -52,17 +52,25 @@ module Blimpy end data end + + def load_fleet + ensure_blimpfile + begin + return load_blimpfile + rescue Blimpy::InvalidBlimpFileError => e + puts "The Blimpfile is invalid!" + puts e.to_s + return nil + end + end end desc 'start', 'Start up a fleet of blimps' method_options :"dry-run" => :boolean def start - ensure_blimpfile - begin - fleet = load_blimpfile - rescue Blimpy::InvalidBlimpFileError => e - puts "The Blimpfile is invalid!" - puts e.to_s + fleet = load_fleet + + if fleet.nil? exit 1 end @@ -74,6 +82,22 @@ module Blimpy fleet.start end + desc 'resume', 'Resume an existing fleet of instances' + def resume + fleet = load_fleet + + if fleet.nil? + exit 1 + end + + if fleet.members.empty? + puts "No fleet running right now, perhaps you should `start` one." + exit 1 + else + fleet.resume(fleet.members) + end + end + desc 'show', 'Show blimp details for running blimps' method_options :tags => :boolean def show