Skip to content

Commit

Permalink
Merge pull request #33 from ekohl/cleanup-prep
Browse files Browse the repository at this point in the history
Various compatible cleanups
  • Loading branch information
ekohl authored Mar 25, 2021
2 parents ad873f5 + e25e04c commit a2a8e5e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 35 deletions.
8 changes: 2 additions & 6 deletions beaker-vagrant.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ Gem::Specification.new do |s|
if RUBY_VERSION < "2.3"
s.add_development_dependency 'fakefs', '~> 0.6', '< 0.14'
else
s.add_development_dependency 'fakefs', '~> 0.6'
s.add_development_dependency 'fakefs', '>= 0.6', '< 2.0'
end
s.add_development_dependency 'rake', '~> 10.1'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'pry', '~> 0.10'

# Documentation dependencies
s.add_development_dependency 'yard'
s.add_development_dependency 'thin'

# Run time dependencies
s.add_runtime_dependency 'stringify-hash', '~> 0.0.0'

end

44 changes: 22 additions & 22 deletions lib/beaker/hypervisor/vagrant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,31 +189,31 @@ def set_all_ssh_config
end

def set_ssh_config host, user
f = Tempfile.new("#{host.name}")
ssh_config = Dir.chdir(@vagrant_path) do
stdin, stdout, stderr, wait_thr = Open3.popen3(@vagrant_env, 'vagrant', 'ssh-config', host.name)
if not wait_thr.value.success?
raise "Failed to 'vagrant ssh-config' for #{host.name}"
end
stdout.read
f = Tempfile.new("#{host.name}")
ssh_config = Dir.chdir(@vagrant_path) do
stdin, stdout, stderr, wait_thr = Open3.popen3(@vagrant_env, 'vagrant', 'ssh-config', host.name)
if not wait_thr.value.success?
raise "Failed to 'vagrant ssh-config' for #{host.name}"
end
#replace hostname with ip
ssh_config = ssh_config.gsub(/Host #{host.name}/, "Host #{host['ip']}") unless not host['ip']
stdout.read
end
#replace hostname with ip
ssh_config = ssh_config.gsub(/Host #{host.name}/, "Host #{host['ip']}") unless not host['ip']

#set the user
ssh_config = ssh_config.gsub(/User vagrant/, "User #{user}")
#set the user
ssh_config = ssh_config.gsub(/User vagrant/, "User #{user}")

if @options[:forward_ssh_agent] == true
ssh_config = ssh_config.gsub(/IdentitiesOnly yes/, "IdentitiesOnly no")
end
if @options[:forward_ssh_agent] == true
ssh_config = ssh_config.gsub(/IdentitiesOnly yes/, "IdentitiesOnly no")
end

f.write(ssh_config)
f.rewind
f.write(ssh_config)
f.rewind

host[:vagrant_ssh_config] = f.path
host['ssh'] = host['ssh'].merge(Net::SSH.configuration_for(host['ip'], f.path))
host['user'] = user
@temp_files << f
host[:vagrant_ssh_config] = f.path
host['ssh'] = host['ssh'].merge(Net::SSH.configuration_for(host['ip'], f.path))
host['user'] = user
@temp_files << f
end

def get_ip_from_vagrant_file(hostname)
Expand Down Expand Up @@ -246,8 +246,8 @@ def initialize(vagrant_hosts, options)
end

def configure(opts = {})
if !@options[:provision]
if !File.file?(@vagrant_file)
unless @options[:provision]
unless File.file?(@vagrant_file)
raise "Beaker is configured with provision = false but no vagrant file was found at #{@vagrant_file}. You need to enable provision"
end

Expand Down
7 changes: 0 additions & 7 deletions lib/beaker/hypervisor/vagrant_libvirt.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
require 'beaker/hypervisor/vagrant'

class Beaker::VagrantLibvirt < Beaker::Vagrant
@memory = nil
@cpu = nil

class << self
attr_reader :memory
end

# Return a random mac address with colons
#
# @return [String] a random mac address
Expand Down

0 comments on commit a2a8e5e

Please sign in to comment.