Change "channel" to "communicate" in all guests

This commit is contained in:
Mitchell Hashimoto 2013-01-30 10:54:53 -08:00
parent f9a843ddd0
commit bb97351060
6 changed files with 52 additions and 52 deletions

View File

@ -21,10 +21,10 @@ module VagrantPlugins
# Remove any previous vagrant configuration in this network # Remove any previous vagrant configuration in this network
# interface's configuration files. # interface's configuration files.
vm.channel.sudo("touch #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}") vm.communicate.sudo("touch #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-p7p#{network[:interface]} > /tmp/vagrant-ifcfg-p7p#{network[:interface]}") vm.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' #{network_scripts_dir}/ifcfg-p7p#{network[:interface]} > /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
vm.channel.sudo("cat /tmp/vagrant-ifcfg-p7p#{network[:interface]} > #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}") vm.communicate.sudo("cat /tmp/vagrant-ifcfg-p7p#{network[:interface]} > #{network_scripts_dir}/ifcfg-p7p#{network[:interface]}")
vm.channel.sudo("rm /tmp/vagrant-ifcfg-p7p#{network[:interface]}") vm.communicate.sudo("rm /tmp/vagrant-ifcfg-p7p#{network[:interface]}")
# Render and upload the network entry file to a deterministic # Render and upload the network entry file to a deterministic
# temporary location. # temporary location.
@ -36,17 +36,17 @@ module VagrantPlugins
temp.write(entry) temp.write(entry)
temp.close temp.close
vm.channel.upload(temp.path, "/tmp/vagrant-network-entry_#{network[:interface]}") vm.communicate.upload(temp.path, "/tmp/vagrant-network-entry_#{network[:interface]}")
end end
# Bring down all the interfaces we're reconfiguring. By bringing down # Bring down all the interfaces we're reconfiguring. By bringing down
# each specifically, we avoid reconfiguring p7p (the NAT interface) so # each specifically, we avoid reconfiguring p7p (the NAT interface) so
# SSH never dies. # SSH never dies.
interfaces.each do |interface| interfaces.each do |interface|
vm.channel.sudo("/sbin/ifdown p7p#{interface} 2> /dev/null", :error_check => false) vm.communicate.sudo("/sbin/ifdown p7p#{interface} 2> /dev/null", :error_check => false)
vm.channel.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-p7p#{interface}") vm.communicate.sudo("cat /tmp/vagrant-network-entry_#{interface} >> #{network_scripts_dir}/ifcfg-p7p#{interface}")
vm.channel.sudo("rm /tmp/vagrant-network-entry_#{interface}") vm.communicate.sudo("rm /tmp/vagrant-network-entry_#{interface}")
vm.channel.sudo("/sbin/ifup p7p#{interface} 2> /dev/null") vm.communicate.sudo("/sbin/ifup p7p#{interface} 2> /dev/null")
end end
end end
@ -60,10 +60,10 @@ module VagrantPlugins
def change_host_name(name) def change_host_name(name)
# Only do this if the hostname is not already set # Only do this if the hostname is not already set
if !vm.channel.test("sudo hostname | grep '#{name}'") if !vm.communicate.test("sudo hostname | grep '#{name}'")
vm.channel.sudo("sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network") vm.communicate.sudo("sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/sysconfig/network")
vm.channel.sudo("hostname #{name}") vm.communicate.sudo("hostname #{name}")
vm.channel.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts") vm.communicate.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
end end
end end
end end

View File

@ -12,7 +12,7 @@ module VagrantPlugins
end end
def halt def halt
vm.channel.sudo("shutdown -p now") vm.communicate.sudo("shutdown -p now")
end end
# TODO: vboxsf is currently unsupported in FreeBSD, if you are able to # TODO: vboxsf is currently unsupported in FreeBSD, if you are able to
@ -28,14 +28,14 @@ module VagrantPlugins
def mount_nfs(ip, folders) def mount_nfs(ip, folders)
folders.each do |name, opts| folders.each do |name, opts|
vm.channel.sudo("mkdir -p #{opts[:guestpath]}") vm.communicate.sudo("mkdir -p #{opts[:guestpath]}")
vm.channel.sudo("mount #{ip}:#{opts[:hostpath]} #{opts[:guestpath]}") vm.communicate.sudo("mount #{ip}:#{opts[:hostpath]} #{opts[:guestpath]}")
end end
end end
def configure_networks(networks) def configure_networks(networks)
# Remove any previous network additions to the configuration file. # Remove any previous network additions to the configuration file.
vm.channel.sudo("sed -i '' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf") vm.communicate.sudo("sed -i '' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf")
networks.each do |network| networks.each do |network|
entry = TemplateRenderer.render("guests/freebsd/network_#{network[:type]}", entry = TemplateRenderer.render("guests/freebsd/network_#{network[:type]}",
@ -47,22 +47,22 @@ module VagrantPlugins
temp.write(entry) temp.write(entry)
temp.close temp.close
vm.channel.upload(temp.path, "/tmp/vagrant-network-entry") vm.communicate.upload(temp.path, "/tmp/vagrant-network-entry")
vm.channel.sudo("su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'") vm.communicate.sudo("su -m root -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'")
vm.channel.sudo("rm /tmp/vagrant-network-entry") vm.communicate.sudo("rm /tmp/vagrant-network-entry")
if network[:type].to_sym == :static if network[:type].to_sym == :static
vm.channel.sudo("ifconfig em#{network[:interface]} inet #{network[:ip]} netmask #{network[:netmask]}") vm.communicate.sudo("ifconfig em#{network[:interface]} inet #{network[:ip]} netmask #{network[:netmask]}")
elsif network[:type].to_sym == :dhcp elsif network[:type].to_sym == :dhcp
vm.channel.sudo("dhclient em#{network[:interface]}") vm.communicate.sudo("dhclient em#{network[:interface]}")
end end
end end
end end
def change_host_name(name) def change_host_name(name)
if !vm.channel.test("hostname -f | grep '^#{name}$' || hostname -s | grep '^#{name}$'") if !vm.communicate.test("hostname -f | grep '^#{name}$' || hostname -s | grep '^#{name}$'")
vm.channel.sudo("sed -i '' 's/^hostname=.*$/hostname=#{name}/' /etc/rc.conf") vm.communicate.sudo("sed -i '' 's/^hostname=.*$/hostname=#{name}/' /etc/rc.conf")
vm.channel.sudo("hostname #{name}") vm.communicate.sudo("hostname #{name}")
end end
end end
end end

View File

@ -13,9 +13,9 @@ module VagrantPlugins
def configure_networks(networks) def configure_networks(networks)
# Remove any previous host only network additions to the interface file # Remove any previous host only network additions to the interface file
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces") vm.communicate.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net") vm.communicate.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
vm.channel.sudo("rm /tmp/vagrant-network-interfaces") vm.communicate.sudo("rm /tmp/vagrant-network-interfaces")
# Configure each network interface # Configure each network interface
networks.each do |network| networks.each do |network|
@ -28,22 +28,22 @@ module VagrantPlugins
temp.write(entry) temp.write(entry)
temp.close temp.close
vm.channel.upload(temp.path, "/tmp/vagrant-network-entry") vm.communicate.upload(temp.path, "/tmp/vagrant-network-entry")
# Configure the interface # Configure the interface
vm.channel.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}") vm.communicate.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null") vm.communicate.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null")
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net") vm.communicate.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
vm.channel.sudo("rm /tmp/vagrant-network-entry") vm.communicate.sudo("rm /tmp/vagrant-network-entry")
vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} start") vm.communicate.sudo("/etc/init.d/net.eth#{network[:interface]} start")
end end
end end
def change_host_name(name) def change_host_name(name)
if !vm.channel.test("sudo hostname --fqdn | grep '#{name}'") if !vm.communicate.test("sudo hostname --fqdn | grep '#{name}'")
vm.channel.sudo("echo 'hostname=#{name.split('.')[0]}' > /etc/conf.d/hostname") vm.communicate.sudo("echo 'hostname=#{name.split('.')[0]}' > /etc/conf.d/hostname")
vm.channel.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts") vm.communicate.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} #{name.split('.')[0]} @' /etc/hosts")
vm.channel.sudo("hostname #{name.split('.')[0]}") vm.communicate.sudo("hostname #{name.split('.')[0]}")
end end
end end
end end

View File

@ -6,7 +6,7 @@ module VagrantPlugins
module GuestOpenBSD module GuestOpenBSD
class Guest < VagrantPlugins::GuestLinux::Guest class Guest < VagrantPlugins::GuestLinux::Guest
def halt def halt
vm.channel.sudo("shutdown -p -h now") vm.communicate.sudo("shutdown -p -h now")
end end
end end
end end

View File

@ -17,14 +17,14 @@ module VagrantPlugins
su_cmd = vm.config.solaris.suexec_cmd su_cmd = vm.config.solaris.suexec_cmd
ifconfig_cmd = "#{su_cmd} /sbin/ifconfig #{device}" ifconfig_cmd = "#{su_cmd} /sbin/ifconfig #{device}"
vm.channel.execute("#{ifconfig_cmd} plumb") vm.communicate.execute("#{ifconfig_cmd} plumb")
if network[:type].to_sym == :static if network[:type].to_sym == :static
vm.channel.execute("#{ifconfig_cmd} inet #{network[:ip]} netmask #{network[:netmask]}") vm.communicate.execute("#{ifconfig_cmd} inet #{network[:ip]} netmask #{network[:netmask]}")
vm.channel.execute("#{ifconfig_cmd} up") vm.communicate.execute("#{ifconfig_cmd} up")
vm.channel.execute("#{su_cmd} sh -c \"echo '#{network[:ip]}' > /etc/hostname.#{device}\"") vm.communicate.execute("#{su_cmd} sh -c \"echo '#{network[:ip]}' > /etc/hostname.#{device}\"")
elsif network[:type].to_sym == :dhcp elsif network[:type].to_sym == :dhcp
vm.channel.execute("#{ifconfig_cmd} dhcp start") vm.communicate.execute("#{ifconfig_cmd} dhcp start")
end end
end end
end end
@ -33,9 +33,9 @@ module VagrantPlugins
su_cmd = vm.config.solaris.suexec_cmd su_cmd = vm.config.solaris.suexec_cmd
# Only do this if the hostname is not already set # Only do this if the hostname is not already set
if !vm.channel.test("#{su_cmd} hostname | grep '#{name}'") if !vm.communicate.test("#{su_cmd} hostname | grep '#{name}'")
vm.channel.execute("#{su_cmd} sh -c \"echo '#{name}' > /etc/nodename\"") vm.communicate.execute("#{su_cmd} sh -c \"echo '#{name}' > /etc/nodename\"")
vm.channel.execute("#{su_cmd} uname -S #{name}") vm.communicate.execute("#{su_cmd} uname -S #{name}")
end end
end end
@ -45,7 +45,7 @@ module VagrantPlugins
# #
# does not exist in /etc/user_attr. TODO # does not exist in /etc/user_attr. TODO
def halt def halt
vm.channel.execute("#{vm.config.solaris.suexec_cmd} /usr/sbin/poweroff") vm.communicate.execute("#{vm.config.solaris.suexec_cmd} /usr/sbin/poweroff")
end end
def mount_shared_folder(name, guestpath, options) def mount_shared_folder(name, guestpath, options)
@ -54,7 +54,7 @@ module VagrantPlugins
group = options[:group] group = options[:group]
# Create the shared folder # Create the shared folder
vm.channel.execute("#{vm.config.solaris.suexec_cmd} mkdir -p #{guestpath}") vm.communicate.execute("#{vm.config.solaris.suexec_cmd} mkdir -p #{guestpath}")
# We have to use this `id` command instead of `/usr/bin/id` since this # We have to use this `id` command instead of `/usr/bin/id` since this
# one accepts the "-u" and "-g" flags. # one accepts the "-u" and "-g" flags.
@ -63,10 +63,10 @@ module VagrantPlugins
# Mount the folder with the proper owner/group # Mount the folder with the proper owner/group
mount_options = "-o uid=`#{id_cmd} -u #{owner}`,gid=`#{id_cmd} -g #{group}`" mount_options = "-o uid=`#{id_cmd} -u #{owner}`,gid=`#{id_cmd} -g #{group}`"
mount_options += ",#{options[:extra]}" if options[:extra] mount_options += ",#{options[:extra]}" if options[:extra]
vm.channel.execute("#{vm.config.solaris.suexec_cmd} /sbin/mount -F vboxfs #{mount_options} #{name} #{guestpath}") vm.communicate.execute("#{vm.config.solaris.suexec_cmd} /sbin/mount -F vboxfs #{mount_options} #{name} #{guestpath}")
# chown the folder to the proper owner/group # chown the folder to the proper owner/group
vm.channel.execute("#{vm.config.solaris.suexec_cmd} chown `#{id_cmd} -u #{owner}`:`#{id_cmd} -g #{group}` #{guestpath}") vm.communicate.execute("#{vm.config.solaris.suexec_cmd} chown `#{id_cmd} -u #{owner}`:`#{id_cmd} -g #{group}` #{guestpath}")
end end
end end
end end

View File

@ -20,7 +20,7 @@ module VagrantPlugins
# Emit an upstart events if upstart is available # Emit an upstart events if upstart is available
folders.each do |name, opts| folders.each do |name, opts|
real_guestpath = expanded_guest_path(opts[:guestpath]) real_guestpath = expanded_guest_path(opts[:guestpath])
vm.channel.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{real_guestpath}") vm.communicate.sudo("[ -x /sbin/initctl ] && /sbin/initctl emit vagrant-mounted MOUNTPOINT=#{real_guestpath}")
end end
end end