Class: VagrantPlugins::Orchestrate::Command::Status

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Util, CommandMixins
Defined in:
lib/vagrant-orchestrate/command/status.rb

Instance Method Summary collapse

Methods included from CommandMixins

#filter_unmanaged, #super_delete

Instance Method Details

#executeObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-orchestrate/command/status.rb', line 18

def execute
  opts = OptionParser.new do |o|
    o.banner = "Usage: vagrant orchestrate status"
    o.separator ""
  end

  argv = parse_options(opts)
  return unless argv

  machines = filter_unmanaged(argv)
  return 0 if machines.empty?

  print_status machines
end


33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/vagrant-orchestrate/command/status.rb', line 33

def print_status(machines)
  # There is some detail output fromt he communicator.download that I
  # don't want to suppress, but I also don't want it to be interspersed
  # with the actual status information. Let's buffer the status output.
  ENV["VAGRANT_ORCHESTRATE_STATUS"] = ""
  @logger.debug("About to download machine status")
  options = {}
  parallel = true
  local_files = []
  @env.batch(parallel) do |batch|
    machines.each do |machine|
      options[:remote_file_path] = RepoStatus.new.remote_path(machine.config.vm.communicator)
      options[:local_file_path] = File.join(@env.tmp_path, "#{machine.name}_status")
      local_files << options[:local_file_path]
      batch.action(machine, :download_status, options)
    end
  end
  @env.ui.info("Current managed server states:")
  @env.ui.info("")
  @env.ui.info(ENV["VAGRANT_ORCHESTRATE_STATUS"].split("\n").sort.join("\n"))
ensure
  local_files.each do |local|
    super_delete(local) if File.exist?(local)
  end
end