Merge pull request #8746 from mastersin/alt

Add ALT Linux platforms guest detection and network configuration support (#8745)
This commit is contained in:
Chris Roberts 2017-09-06 17:49:38 -07:00 committed by GitHub
commit 2451c859e8
19 changed files with 793 additions and 0 deletions

View File

@ -0,0 +1,46 @@
module VagrantPlugins
module GuestALT
module Cap
class ChangeHostName
def self.change_host_name(machine, name)
comm = machine.communicate
if !comm.test("hostname -f | grep '^#{name}$'", sudo: false)
basename = name.split('.', 2)[0]
comm.sudo <<-EOH.gsub(/^ {14}/, '')
# Save current hostname saved in /etc/hosts
CURRENT_HOSTNAME_FULL="$(hostname -f)"
CURRENT_HOSTNAME_SHORT="$(hostname -s)"
# New hostname to be saved in /etc/hosts
NEW_HOSTNAME_FULL='#{name}'
NEW_HOSTNAME_SHORT="${NEW_HOSTNAME_FULL%%.*}"
# Update sysconfig
sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network
# Set the hostname - use hostnamectl if available
if command -v hostnamectl; then
hostnamectl set-hostname --static '#{name}'
hostnamectl set-hostname --transient '#{name}'
else
hostname '#{name}'
fi
# Update ourselves in /etc/hosts
if grep -w "$CURRENT_HOSTNAME_FULL" /etc/hosts; then
sed -i -e "s/\(\s\)$CURRENT_HOSTNAME_FULL\(\s\)/\1$NEW_HOSTNAME_FULL\2/g" -e "s/\(\s\)$CURRENT_HOSTNAME_FULL$/\1$NEW_HOSTNAME_FULL/g" /etc/hosts
fi
if grep -w "$CURRENT_HOSTNAME_SHORT" /etc/hosts; then
sed -i -e "s/\(\s\)$CURRENT_HOSTNAME_SHORT\(\s\)/\1$NEW_HOSTNAME_SHORT\2/g" -e "s/\(\s\)$CURRENT_HOSTNAME_SHORT$/\1$NEW_HOSTNAME_SHORT/g" /etc/hosts
fi
# Restart network
service network restart
EOH
end
end
end
end
end
end

View File

@ -0,0 +1,126 @@
require "tempfile"
require_relative "../../../../lib/vagrant/util/template_renderer"
module VagrantPlugins
module GuestALT
module Cap
class ConfigureNetworks
include Vagrant::Util
extend Vagrant::Util::GuestInspection::Linux
def self.configure_networks(machine, networks)
comm = machine.communicate
network_scripts_dir = machine.guest.capability(:network_scripts_dir)
commands = {:start => [], :middle => [], :end => []}
interfaces = machine.guest.capability(:network_interfaces)
# Check if NetworkManager is installed on the system
nmcli_installed = nmcli?(comm)
networks.each.with_index do |network, i|
network[:device] = interfaces[network[:interface]]
extra_opts = machine.config.vm.networks[i].last.dup
if nmcli_installed
# Now check if the device is actively being managed by NetworkManager
nm_controlled = nm_controlled?(comm, network[:device])
end
if !extra_opts.key?(:nm_controlled)
extra_opts[:nm_controlled] = !!nm_controlled
end
extra_opts[:nm_controlled] = case extra_opts[:nm_controlled]
when true
"yes"
when false, nil
"no"
else
extra_opts[:nm_controlled].to_s
end
if extra_opts[:nm_controlled] == "yes" && !nmcli_installed
raise Vagrant::Errors::NetworkManagerNotInstalled, device: network[:device]
end
# Render a new configuration
template_options = network.merge(extra_opts)
# ALT expects netmasks to be in the CIDR notation, but users may
# specify IPV4 netmasks like "255.255.255.0". This magic converts
# the netmask to the proper value.
if template_options[:netmask] && template_options[:netmask].to_s.include?(".")
template_options[:netmask] = (32-Math.log2((IPAddr.new(template_options[:netmask], Socket::AF_INET).to_i^0xffffffff)+1)).to_i
end
options_entry = TemplateRenderer.render("guests/alt/network_#{network[:type]}", options: template_options)
# Upload the new configuration
options_remote_path = "/tmp/vagrant-network-entry-#{network[:device]}-#{Time.now.to_i}-#{i}"
ipv4_address_remote_path = "/tmp/vagrant-network-ipv4-address-entry-#{network[:device]}-#{Time.now.to_i}-#{i}"
ipv4_route_remote_path = "/tmp/vagrant-network-ipv4-route-entry-#{network[:device]}-#{Time.now.to_i}-#{i}"
Tempfile.open("vagrant-alt-configure-networks") do |f|
f.binmode
f.write(options_entry)
f.fsync
f.close
machine.communicate.upload(f.path, options_remote_path)
end
# Add the new interface and bring it back up
iface_path = "#{network_scripts_dir}/ifaces/#{network[:device]}"
if network[:type].to_sym == :static
ipv4_address_entry = TemplateRenderer.render("guests/alt/network_ipv4address", options: template_options)
# Upload the new ipv4address configuration
Tempfile.open("vagrant-alt-configure-ipv4-address") do |f|
f.binmode
f.write(ipv4_address_entry)
f.fsync
f.close
machine.communicate.upload(f.path, ipv4_address_remote_path)
end
ipv4_route_entry = TemplateRenderer.render("guests/alt/network_ipv4route", options: template_options)
# Upload the new ipv4route configuration
Tempfile.open("vagrant-alt-configure-ipv4-route") do |f|
f.binmode
f.write(ipv4_route_entry)
f.fsync
f.close
machine.communicate.upload(f.path, ipv4_route_remote_path)
end
end
if nm_controlled and extra_opts[:nm_controlled] == "yes"
commands[:start] << "nmcli d disconnect iface '#{network[:device]}'"
else
commands[:start] << "/sbin/ifdown '#{network[:device]}'"
end
commands[:middle] << "mkdir -p '#{iface_path}'"
commands[:middle] << "mv -f '#{options_remote_path}' '#{iface_path}/options'"
if network[:type].to_sym == :static
commands[:middle] << "mv -f '#{ipv4_address_remote_path}' '#{iface_path}/ipv4address'"
commands[:middle] << "mv -f '#{ipv4_route_remote_path}' '#{iface_path}/ipv4route'"
end
if extra_opts[:nm_controlled] == "no"
commands[:end] << "/sbin/ifup '#{network[:device]}'"
end
end
if nmcli_installed
commands[:middle] << "((systemctl | grep NetworkManager.service) && systemctl restart NetworkManager) || " \
"(test -f /etc/init.d/NetworkManager && /etc/init.d/NetworkManager restart)"
end
commands = commands[:start] + commands[:middle] + commands[:end]
comm.sudo(commands.join("\n"))
comm.wait_for_ready(5)
end
end
end
end
end

View File

@ -0,0 +1,63 @@
module VagrantPlugins
module GuestALT
module Cap
class Flavor
def self.flavor(machine)
comm = machine.communicate
# Read the version file
if comm.test("test -f /etc/os-release")
name = nil
comm.sudo("grep NAME /etc/os-release") do |type, data|
if type == :stdout
name = data.split("=")[1].gsub!(/\A"|"\Z/, '')
end
end
if !name.nil? and name == "Sisyphus"
return :alt
end
version = nil
comm.sudo("grep VERSION_ID /etc/os-release") do |type, data|
if type == :stdout
verstr = data.split("=")[1]
if verstr == "p8"
version = 8
elsif verstr =~ /^[[\d]]/
version = verstr.chomp.to_i
subversion = verstr.chomp.split(".")[1].to_i
if subversion > 90
version += 1
end
end
end
end
if version.nil? or version == 0
return :alt
else
return :"alt_#{version}"
end
else
output = ""
comm.sudo("cat /etc/altlinux-release") do |_, data|
output = data
end
# Detect various flavors we care about
if output =~ /(ALT SP|ALT Education|ALT Workstation|ALT Workstation K|ALT Linux starter kit)\s*8(\.[1-9])?( .+)?/i
return :alt_8
elsif output =~ /ALT\s+8(\.[1-9])?( .+)?\s.+/i
return :alt_8
elsif output =~ /ALT Linux p8( .+)?/i
return :alt_8
else
return :alt
end
end
end
end
end
end
end

View File

@ -0,0 +1,11 @@
module VagrantPlugins
module GuestALT
module Cap
class NetworkScriptsDir
def self.network_scripts_dir(machine)
"/etc/net"
end
end
end
end
end

View File

@ -0,0 +1,13 @@
module VagrantPlugins
module GuestALT
module Cap
class RSync
def self.rsync_install(machine)
machine.communicate.sudo <<-EOH.gsub(/^ {12}/, '')
apt-get install -y -qq install rsync
EOH
end
end
end
end
end

View File

@ -0,0 +1,9 @@
module VagrantPlugins
module GuestALT
class Guest < Vagrant.plugin("2", :guest)
def detect?(machine)
machine.communicate.test("cat /etc/altlinux-release")
end
end
end
end

View File

@ -0,0 +1,40 @@
require "vagrant"
module VagrantPlugins
module GuestALT
class Plugin < Vagrant.plugin("2")
name "ALT Platform guest"
description "ALT Platform guest support."
guest(:alt, :redhat) do
require_relative "guest"
Guest
end
guest_capability(:alt, :change_host_name) do
require_relative "cap/change_host_name"
Cap::ChangeHostName
end
guest_capability(:alt, :configure_networks) do
require_relative "cap/configure_networks"
Cap::ConfigureNetworks
end
guest_capability(:alt, :flavor) do
require_relative "cap/flavor"
Cap::Flavor
end
guest_capability(:alt, :network_scripts_dir) do
require_relative "cap/network_scripts_dir"
Cap::NetworkScriptsDir
end
guest_capability(:alt, :rsync_install) do
require_relative "cap/rsync"
Cap::RSync
end
end
end
end

View File

@ -0,0 +1,43 @@
require "vagrant/util/subprocess"
require "vagrant/util/which"
module VagrantPlugins
module HostALT
module Cap
class NFS
def self.nfs_check_command(env)
if systemd?
return "systemctl status --no-pager nfs-server.service"
else
return "/etc/init.d/nfs status"
end
end
def self.nfs_start_command(env)
if systemd?
return "systemctl start rpcbind nfs-server.service"
else
return "/etc/init.d/nfs restart"
end
end
def self.nfs_installed(environment)
if systemd?
system("systemctl --no-pager --no-legend --plain list-unit-files --all --type=service | grep --fixed-strings --quiet nfs-server.service")
else
system("rpm -q nfs-server --quiet 2>&1")
end
end
protected
# This tests to see if systemd is used on the system. This is used
# in newer versions of ALT, and requires a change in behavior.
def self.systemd?
result = Vagrant::Util::Subprocess.execute("ps", "-o", "comm=", "1")
return result.stdout.chomp == "systemd"
end
end
end
end
end

11
plugins/hosts/alt/host.rb Normal file
View File

@ -0,0 +1,11 @@
require "vagrant"
module VagrantPlugins
module HostALT
class Host < Vagrant.plugin("2", :host)
def detect?(env)
File.exist?("/etc/altlinux-release")
end
end
end
end

View File

@ -0,0 +1,32 @@
require "vagrant"
module VagrantPlugins
module HostALT
class Plugin < Vagrant.plugin("2")
name "ALT Platform host"
description "ALT Platform host support."
host("alt", "linux") do
require_relative "host"
Host
end
host_capability("alt", "nfs_installed") do
require_relative "cap/nfs"
Cap::NFS
end
# Linux-specific helpers we need to determine paths that can
# be overriden.
host_capability("alt", "nfs_check_command") do
require_relative "cap/nfs"
Cap::NFS
end
host_capability("alt", "nfs_start_command") do
require_relative "cap/nfs"
Cap::NFS
end
end
end
end

View File

@ -0,0 +1,7 @@
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
TYPE=eth
NM_CONTROLLED=<%= options.fetch(:nm_controlled, "no") %>
BOOTPROTO=dhcp
ONBOOT=yes
#VAGRANT-END

View File

@ -0,0 +1,3 @@
#VAGRANT-BEGIN
<%= options[:ip] %>/<%= options[:netmask] %>
#VAGRANT-END

View File

@ -0,0 +1,5 @@
#VAGRANT-BEGIN
<% if options[:gateway] %>
default via <%= options[:gateway] %>
<% end %>
#VAGRANT-END

View File

@ -0,0 +1,7 @@
#VAGRANT-BEGIN
# The contents below are automatically generated by Vagrant. Do not modify.
TYPE=eth
NM_CONTROLLED=<%= options.fetch(:nm_controlled, "no") %>
BOOTPROTO=static
ONBOOT=yes
#VAGRANT-END

View File

@ -0,0 +1,42 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestALT::Cap::ChangeHostName" do
let(:caps) do
VagrantPlugins::GuestALT::Plugin
.components
.guest_capabilities[:alt]
end
let(:machine) { double("machine") }
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
before do
allow(machine).to receive(:communicate).and_return(comm)
end
after do
comm.verify_expectations!
end
describe ".change_host_name" do
let(:cap) { caps.get(:change_host_name) }
let(:name) { "banana-rama.example.com" }
it "sets the hostname" do
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 1)
cap.change_host_name(machine, name)
expect(comm.received_commands[1]).to match(/\/etc\/sysconfig\/network/)
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname --static '#{name}'/)
expect(comm.received_commands[1]).to match(/hostnamectl set-hostname --transient '#{name}'/)
expect(comm.received_commands[1]).to match(/service network restart/)
end
it "does not change the hostname if already set" do
comm.stub_command("hostname -f | grep '^#{name}$'", exit_code: 0)
cap.change_host_name(machine, name)
expect(comm.received_commands.size).to eq(1)
end
end
end

View File

@ -0,0 +1,213 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestALT::Cap::ConfigureNetworks" do
let(:caps) do
VagrantPlugins::GuestALT::Plugin
.components
.guest_capabilities[:alt]
end
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
let(:config) { double("config", vm: vm) }
let(:guest) { double("guest") }
let(:machine) { double("machine", guest: guest, config: config) }
let(:networks){ [[{}], [{}]] }
let(:vm){ double("vm", networks: networks) }
before do
allow(machine).to receive(:communicate).and_return(comm)
end
after do
comm.verify_expectations!
end
describe ".configure_networks" do
let(:cap) { caps.get(:configure_networks) }
before do
allow(guest).to receive(:capability)
.with(:flavor)
.and_return(:alt)
allow(guest).to receive(:capability)
.with(:network_scripts_dir)
.and_return("/etc/net")
allow(guest).to receive(:capability)
.with(:network_interfaces)
.and_return(["eth1", "eth2"])
end
let(:network_1) do
{
interface: 0,
type: "dhcp",
}
end
let(:network_2) do
{
interface: 1,
type: "static",
ip: "33.33.33.10",
netmask: "255.255.0.0",
gateway: "33.33.0.1",
}
end
context "with NetworkManager installed" do
before do
allow(cap).to receive(:nmcli?).and_return true
end
context "with devices managed by NetworkManager" do
before do
allow(cap).to receive(:nm_controlled?).and_return true
end
context "with nm_controlled option omitted" do
it "downs networks via nmcli, creates ifaces and restart NetworksManager" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/nmcli.*disconnect/)
expect(comm.received_commands[0]).to match(/mkdir.*\/etc\/net\/ifaces/)
expect(comm.received_commands[0]).to match(/NetworkManager/)
expect(comm.received_commands[0]).to_not match(/ifdown|ifup/)
end
end
context "with nm_controlled option set to true" do
let(:networks){ [[{nm_controlled: true}], [{nm_controlled: true}]] }
it "downs networks via nmcli, creates ifaces and restart NetworksManager" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/nmcli.*disconnect/)
expect(comm.received_commands[0]).to match(/mkdir.*\/etc\/net\/ifaces/)
expect(comm.received_commands[0]).to match(/NetworkManager/)
expect(comm.received_commands[0]).to_not match(/(ifdown|ifup)/)
end
end
context "with nm_controlled option set to false" do
let(:networks){ [[{nm_controlled: false}], [{nm_controlled: false}]] }
it "downs networks manually, creates ifaces, starts networks manually and restart NetworksManager" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/ifdown/)
expect(comm.received_commands[0]).to match(/mkdir.*\/etc\/net\/ifaces/)
expect(comm.received_commands[0]).to match(/ifup/)
expect(comm.received_commands[0]).to match(/NetworkManager/)
expect(comm.received_commands[0]).to_not match(/nmcli/)
end
end
context "with nm_controlled option set to false on first device" do
let(:networks){ [[{nm_controlled: false}], [{nm_controlled: true}]] }
it "downs networks, creates ifaces and starts the networks with one managed manually and one NetworkManager controlled" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/ifdown/)
expect(comm.received_commands[0]).to match(/nmcli.*disconnect/)
expect(comm.received_commands[0]).to match(/mkdir.*\/etc\/net\/ifaces/)
expect(comm.received_commands[0]).to match(/ifup/)
expect(comm.received_commands[0]).to match(/NetworkManager/)
end
end
end
context "with devices not managed by NetworkManager" do
before do
allow(cap).to receive(:nm_controlled?).and_return false
end
context "with nm_controlled option omitted" do
it "creates and starts the networks manually" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/ifdown/)
expect(comm.received_commands[0]).to match(/mkdir.*\/etc\/net\/ifaces/)
expect(comm.received_commands[0]).to match(/ifup/)
expect(comm.received_commands[0]).to match(/NetworkManager/)
expect(comm.received_commands[0]).to_not match(/nmcli/)
end
end
context "with nm_controlled option set to true" do
let(:networks){ [[{nm_controlled: true}], [{nm_controlled: true}]] }
it "creates and starts the networks via nmcli" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/ifdown/)
expect(comm.received_commands[0]).to match(/mkdir.*\/etc\/net\/ifaces/)
expect(comm.received_commands[0]).to match(/NetworkManager/)
expect(comm.received_commands[0]).to_not match(/ifup/)
end
end
context "with nm_controlled option set to false" do
let(:networks){ [[{nm_controlled: false}], [{nm_controlled: false}]] }
it "creates and starts the networks via ifup " do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/ifdown/)
expect(comm.received_commands[0]).to match(/mkdir.*\/etc\/net\/ifaces/)
expect(comm.received_commands[0]).to match(/ifup/)
expect(comm.received_commands[0]).to match(/NetworkManager/)
expect(comm.received_commands[0]).to_not match(/nmcli/)
end
end
context "with nm_controlled option set to false on first device" do
let(:networks){ [[{nm_controlled: false}], [{nm_controlled: true}]] }
it "creates and starts the networks with one managed manually and one NetworkManager controlled" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/ifdown/)
expect(comm.received_commands[0]).to match(/mkdir.*\/etc\/net\/ifaces/)
expect(comm.received_commands[0]).to match(/ifup/)
expect(comm.received_commands[0]).to match(/NetworkManager/)
expect(comm.received_commands[0]).to_not match(/nmcli.*disconnect/)
end
end
end
end
context "without NetworkManager installed" do
before do
allow(cap).to receive(:nmcli?).and_return false
end
context "with nm_controlled option omitted" do
it "creates and starts the networks manually" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/ifdown/)
expect(comm.received_commands[0]).to match(/mkdir.*\/etc\/net\/ifaces/)
expect(comm.received_commands[0]).to match(/ifup/)
expect(comm.received_commands[0]).to_not match(/nmcli/)
expect(comm.received_commands[0]).to_not match(/NetworkManager/)
end
end
context "with nm_controlled option omitted" do
let(:networks){ [[{nm_controlled: false}], [{nm_controlled: false}]] }
it "creates and starts the networks manually" do
cap.configure_networks(machine, [network_1, network_2])
expect(comm.received_commands[0]).to match(/ifdown/)
expect(comm.received_commands[0]).to match(/mkdir.*\/etc\/net\/ifaces/)
expect(comm.received_commands[0]).to match(/ifup/)
expect(comm.received_commands[0]).to_not match(/nmcli/)
expect(comm.received_commands[0]).to_not match(/NetworkManager/)
end
end
context "with nm_controlled option set" do
let(:networks){ [[{nm_controlled: false}], [{nm_controlled: true}]] }
it "raises an error" do
expect{ cap.configure_networks(machine, [network_1, network_2]) }.to raise_error(Vagrant::Errors::NetworkManagerNotInstalled)
end
end
end
end
end

View File

@ -0,0 +1,72 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestALT::Cap::Flavor" do
let(:caps) do
VagrantPlugins::GuestALT::Plugin
.components
.guest_capabilities[:alt]
end
let(:machine) { double("machine") }
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
before do
allow(machine).to receive(:communicate).and_return(comm)
end
after do
comm.verify_expectations!
end
describe ".flavor" do
let(:cap) { caps.get(:flavor) }
context "without /etc/os-release file" do
{
"ALT 8.1 Server" => :alt_8,
"ALT Education 8.1" => :alt_8,
"ALT Workstation 8.1" => :alt_8,
"ALT Workstation K 8.1 (Centaurea Ruthenica)" => :alt_8,
"ALT Linux p8 (Hypericum)" => :alt_8,
"ALT Sisyphus (unstable) (sisyphus)" => :alt,
"ALT Linux Sisyphus (unstable)" => :alt,
"ALT Linux 6.0.1 Spt (separator)" => :alt,
"ALT Linux 7.0.5 School Master" => :alt,
"ALT starter kit (Hypericum)" => :alt,
"ALT" => :alt,
"Simply" => :alt,
}.each do |str, expected|
it "returns #{expected} for #{str} in /etc/altlinux-release" do
comm.stub_command("test -f /etc/os-release", exit_code: 1)
comm.stub_command("cat /etc/altlinux-release", stdout: str)
expect(cap.flavor(machine)).to be(expected)
end
end
end
context "with /etc/os-release file" do
{
[ "NAME=\"Sisyphus\"", "VERSION_ID=20161130" ] => :alt,
[ "NAME=\"ALT Education\"", "VERSION_ID=8.1" ] => :alt_8,
[ "NAME=\"ALT Server\"", "VERSION_ID=8.1" ] => :alt_8,
[ "NAME=\"ALT SPServer\"", "VERSION_ID=8.0" ] => :alt_8,
[ "NAME=\"starter kit\"", "VERSION_ID=p8" ] => :alt_8,
[ "NAME=\"ALT Linux\"", "VERSION_ID=8.0.0" ] => :alt_8,
[ "NAME=\"Simply Linux\"", "VERSION_ID=7.95.0" ] => :alt_8,
[ "NAME=\"ALT Linux\"", "VERSION_ID=7.0.5" ] => :alt_7,
[ "NAME=\"School Junior\"", "VERSION_ID=7.0.5" ] => :alt_7,
}.each do |strs, expected|
it "returns #{expected} for #{strs[0]} and #{strs[1]} in /etc/os-release" do
comm.stub_command("test -f /etc/os-release", exit_code: 0)
comm.stub_command("grep NAME /etc/os-release", stdout: strs[0])
comm.stub_command("grep VERSION_ID /etc/os-release", stdout: strs[1])
expect(cap.flavor(machine)).to be(expected)
end
end
end
end
end

View File

@ -0,0 +1,21 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestALT::Cap::NetworkScriptsDir" do
let(:caps) do
VagrantPlugins::GuestALT::Plugin
.components
.guest_capabilities[:alt]
end
let(:machine) { double("machine") }
describe ".network_scripts_dir" do
let(:cap) { caps.get(:network_scripts_dir) }
let(:name) { "banana-rama.example.com" }
it "is /etc/net" do
expect(cap.network_scripts_dir(machine)).to eq("/etc/net")
end
end
end

View File

@ -0,0 +1,29 @@
require_relative "../../../../base"
describe "VagrantPlugins::GuestALT::Cap:RSync" do
let(:caps) do
VagrantPlugins::GuestALT::Plugin
.components
.guest_capabilities[:alt]
end
let(:machine) { double("machine") }
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) }
before do
allow(machine).to receive(:communicate).and_return(comm)
end
after do
comm.verify_expectations!
end
describe ".rsync_install" do
let(:cap) { caps.get(:rsync_install) }
it "installs rsync" do
cap.rsync_install(machine)
expect(comm.received_commands[0]).to match(/install rsync/)
end
end
end