Created
February 16, 2015 20:27
-
-
Save mwrock/5cd2b2f8fc8148c453e2 to your computer and use it in GitHub Desktop.
vsphere driver transport
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def transport_for(machine_spec, machine_options, vm) | |
if is_windows?(vm) | |
create_winrm_transport(machine_spec, machine_options, vm) | |
else | |
create_ssh_transport(machine_spec, machine_options, vm) | |
end | |
end | |
def create_winrm_transport(machine_spec, machine_options, vm) | |
require 'chef_metal/transport/winrm' | |
bootstrap_options = bootstrap_options_for(machine_spec, machine_options) | |
ssh_options = bootstrap_options[:ssh] | |
remote_host = machine_spec.location['ipaddress'] || ip_for(bootstrap_options, vm) | |
winrm_options = {:user => "#{ssh_options[:user]}", :pass => ssh_options[:password]} | |
if ssh_options[:user].include?("\\") | |
winrm_options[:disable_sspi] = true | |
else | |
winrm_options[:basic_auth_only] = true | |
end | |
ChefMetal::Transport::WinRM.new("ssh_options[:scheme]://#{remote_host}:ssh_options[:port]/wsman", :plaintext, winrm_options, config) | |
end | |
def create_ssh_transport(machine_spec, machine_options, vm) | |
require 'chef_metal/transport/ssh' | |
bootstrap_options = bootstrap_options_for(machine_spec, machine_options) | |
ssh_options = bootstrap_options[:ssh] | |
ssh_user = ssh_options[:user] | |
remote_host = machine_spec.location['ipaddress'] || ip_for(bootstrap_options, vm) | |
ChefMetal::Transport::SSH.new(remote_host, ssh_user, ssh_options, {}, config) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment