mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
Some other minor changes include: * add back the user level boostrap scripts, useful in that case to pull latest released LS * cleanup formatting for specs and fixed bootstrap scripts for redhats * make the latest logstash version available from the current platform config file * make sure debian based machines use java8 * make sure to use hostname and not just ip:port address when reporting the names Fixes #5350
52 lines
1.4 KiB
Ruby
52 lines
1.4 KiB
Ruby
# encoding: utf-8
|
|
require "open3"
|
|
require "bundler"
|
|
require_relative "command"
|
|
|
|
module LogStash
|
|
class VagrantHelpers
|
|
|
|
def self.halt(machines="")
|
|
CommandExecutor.run!("vagrant halt #{machines.join(' ')}")
|
|
end
|
|
|
|
def self.destroy(machines="")
|
|
CommandExecutor.run!("vagrant destroy --force #{machines.join(' ')}")
|
|
end
|
|
|
|
def self.bootstrap(machines="")
|
|
CommandExecutor.run!("vagrant up #{machines.join(' ')}")
|
|
end
|
|
|
|
def self.save_snapshot(machine="")
|
|
CommandExecutor.run!("vagrant snapshot save #{machine} #{machine}-snapshot")
|
|
end
|
|
|
|
def self.restore_snapshot(machine="")
|
|
CommandExecutor.run!("vagrant snapshot restore #{machine} #{machine}-snapshot")
|
|
end
|
|
|
|
def self.fetch_config
|
|
machines = CommandExecutor.run!("vagrant status").stdout.split("\n").select { |l| l.include?("running") }.map { |r| r.split(' ')[0]}
|
|
CommandExecutor.run!("vagrant ssh-config #{machines.join(' ')}")
|
|
end
|
|
|
|
def self.parse(lines)
|
|
hosts, host = [], {}
|
|
lines.each do |line|
|
|
if line.match(/Host\s(.*)$/)
|
|
host = { :host => line.gsub("Host","").strip }
|
|
elsif line.match(/HostName\s(.*)$/)
|
|
host[:hostname] = line.gsub("HostName","").strip
|
|
elsif line.match(/Port\s(.*)$/)
|
|
host[:port] = line.gsub("Port","").strip
|
|
elsif line.empty?
|
|
hosts << host
|
|
host = {}
|
|
end
|
|
end
|
|
hosts << host
|
|
hosts
|
|
end
|
|
end
|
|
end
|