lib/kitchen/driver/helpers.rb in kitchen-vagrant-1.5.2 vs lib/kitchen/driver/helpers.rb in kitchen-vagrant-1.6.0
- old
+ new
@@ -74,10 +74,11 @@
debug("#Local Command BEGIN (#{cmd})")
sh = Mixlib::ShellOut.new(cmd, options)
sh.run_command
debug("Local Command END #{Util.duration(sh.execution_time)}")
raise "Failed: #{sh.stderr}" if sh.error?
+
stdout = sanitize_stdout(sh.stdout)
JSON.parse(stdout) if stdout.length > 2
end
def sanitize_stdout(stdout)
@@ -89,22 +90,24 @@
if default_switch_object.nil? ||
!default_switch_object.key?("Name") ||
default_switch_object["Name"].empty?
raise "Failed to find a default VM Switch."
end
+
default_switch_object["Name"]
end
def hyperv_default_switch_ps
<<-VMSWITCH
- Get-DefaultVMSwitch #{ENV['KITCHEN_HYPERV_SWITCH']} | ConvertTo-Json
+ Get-DefaultVMSwitch #{ENV["KITCHEN_HYPERV_SWITCH"]} | ConvertTo-Json
VMSWITCH
end
private
def ruby_array_to_ps_array(list)
return "@()" if list.nil? || list.empty?
+
list.to_s.tr("[]", "()").prepend("@")
end
end
end
end