Sha256: 62f7e74ec34f3a1c337df92b084d84c988150b48245d1c9a4cda6daabe9bba6b

Contents?: true

Size: 832 Bytes

Versions: 2

Compression:

Stored size: 832 Bytes

Contents

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

    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

2 entries across 2 versions & 1 rubygems

Version Path
kontena-plugin-vagrant-0.2.0 lib/kontena/plugin/vagrant/nodes/stop_command.rb
kontena-plugin-vagrant-0.2.0.pre2 lib/kontena/plugin/vagrant/nodes/stop_command.rb