Class: Central::Cli::Nodes::Vagrant::StopCommand

Inherits:
Clamp::Command
  • Object
show all
Includes:
Common, StackOptions
Defined in:
lib/central/cli/nodes/vagrant/stop_command.rb

Instance Method Summary collapse

Methods included from StackOptions

included

Methods included from Common

#access_token=, #add_master, #api_url, #api_url=, #clear_current_stack, #client, #current_master, #current_master=, #current_master_index, #current_stack, #current_stack=, #ensure_custom_ssl_ca, #require_api_url, #require_current_stack, #require_token, #reset_client, #save_settings, #settings, #settings_filename

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/central/cli/nodes/vagrant/stop_command.rb', line 8

def execute
  require_api_url
  require_current_stack

  require 'central/machine/vagrant'
  vagrant_path = "#{Dir.home}/.central/#{current_stack}/#{name}"
  abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
  Dir.chdir(vagrant_path) do
    ShellSpinner "Stopping Vagrant machine #{name.colorize(:cyan)} " do
      Open3.popen2('vagrant halt') do |_stdin, output, _wait|
        while o = output.gets
          print o if ENV['DEBUG']
        end
      end
    end
  end
end