Sha256: 358356dba80c621b2c46446fa9cedd5c90c2be84e9b740bf013e3e616c5ff2a4

Contents?: true

Size: 793 Bytes

Versions: 5

Compression:

Stored size: 793 Bytes

Contents

module Kontena::Plugin::Vagrant::Nodes
  class StopCommand < Clamp::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions

    parameter "NAME", "Node name"

    def execute
      require_api_url
      require_current_grid

      require_relative '../../../machine/vagrant'
      
      vagrant_path = "#{Dir.home}/.kontena/#{current_grid}/#{name}"
      abort("Cannot find Vagrant node #{name}".colorize(:red)) unless Dir.exist?(vagrant_path)
      Dir.chdir(vagrant_path) do
          spinner "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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kontena-plugin-vagrant-0.2.7 lib/kontena/plugin/vagrant/nodes/stop_command.rb
kontena-plugin-vagrant-0.2.6 lib/kontena/plugin/vagrant/nodes/stop_command.rb
kontena-plugin-vagrant-0.2.5 lib/kontena/plugin/vagrant/nodes/stop_command.rb
kontena-plugin-vagrant-0.2.2 lib/kontena/plugin/vagrant/nodes/stop_command.rb
kontena-plugin-vagrant-0.2.1 lib/kontena/plugin/vagrant/nodes/stop_command.rb