lib/kitchen/driver/vagrant_winrm.rb in kitchen-vagrant_winrm-0.1.0.dev vs lib/kitchen/driver/vagrant_winrm.rb in kitchen-vagrant_winrm-0.1.1
- old
+ new
@@ -1,8 +1,9 @@
require 'fileutils'
require 'rubygems/version'
require 'kitchen'
+require 'tempfile'
module Kitchen
module Driver
@@ -51,28 +52,28 @@
run_remote provisioner.install_command
run_remote provisioner.init_command
Dir.glob("#{provisioner.sandbox_path}/*").each do |file|
- remote_file = File.join(provisioner[:root_path], File.basename(file))
- run "vagrant winrm-upload \"#{file}\" \"#{remote_file}\""
+ upload file, File.join(provisioner[:root_path], File.basename(file))
end
run_remote provisioner.prepare_command
run_remote provisioner.run_command
ensure
provisioner && provisioner.cleanup_sandbox
end
def setup(state)
create_vagrantfile
- run "vagrant winrm -c \"#{busser_setup_cmd}\""
+ run_remote busser_setup_cmd
end
def verify(state)
create_vagrantfile
- run "vagrant winrm -c \"#{busser_sync_cmd}\" -c \"#{busser_run_cmd}\""
+ run_remote busser_sync_cmd
+ run_remote busser_run_cmd
end
def destroy(state)
return unless state[:created]
@@ -96,11 +97,19 @@
protected
WEBSITE = 'http://downloads.vagrantup.com/'
MIN_VER = '1.1.0'
- def run_remote(cmd, options = {})
- run "vagrant winrm -c \"#{cmd}\""
+ def upload(source, destination)
+ debug("Uploading #{source} to #{destination} through WinRM")
+ run "vagrant winrm-upload \"#{source}\" \"#{destination}\""
+ end
+
+ def run_remote(cmd)
+ return unless cmd
+
+ debug("Executing winRM command #{cmd}")
+ run "vagrant winrm -c \"#{cmd.gsub(/["`\\\x0]/, '\\\\\0')}\""
end
def run(cmd, options = {})
cmd = "echo #{cmd}" if config[:dry_run]
run_command(cmd, { :cwd => vagrant_root }.merge(options))