Class: VagrantPlugins::WinAzure::Driver
- Inherits:
-
HyperV::Driver
- Object
- HyperV::Driver
- VagrantPlugins::WinAzure::Driver
- Defined in:
- lib/vagrant-azure/driver.rb
Instance Method Summary collapse
- #check_winrm ⇒ Object
-
#initialize(machine) ⇒ Driver
constructor
A new instance of Driver.
- #remote_credentials ⇒ Object
- #run_remote_ps(command, &block) ⇒ Object
- #ssh_info ⇒ Object
- #upload(from, to) ⇒ Object
Constructor Details
#initialize(machine) ⇒ Driver
Returns a new instance of Driver.
11 12 13 14 |
# File 'lib/vagrant-azure/driver.rb', line 11 def initialize(machine) @id = machine.id @machine = machine end |
Instance Method Details
#check_winrm ⇒ Object
63 64 65 66 |
# File 'lib/vagrant-azure/driver.rb', line 63 def check_winrm script_path = local_script_path('check_winrm.ps1') execute(script_path, remote_credentials) end |
#remote_credentials ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/vagrant-azure/driver.rb', line 23 def remote_credentials @remote_credentials ||= { guest_ip: ssh_info[:host], guest_port: ssh_info[:port], username: ssh_info[:username], password: ssh_info[:password] } end |
#run_remote_ps(command, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vagrant-azure/driver.rb', line 32 def run_remote_ps(command, &block) = remote_credentials.merge(command: command) script_path = local_script_path('run_in_remote.ps1') = [] .each do |key, value| << "-#{key}" << "'#{value}'" end << '-ErrorAction' << 'Stop' opts = { notify: [:stdout, :stderr, :stdin] } Vagrant::Util::PowerShell.execute( script_path, *, **opts, &block ) end |
#ssh_info ⇒ Object
16 17 18 19 20 21 |
# File 'lib/vagrant-azure/driver.rb', line 16 def ssh_info @ssh_info ||= @machine.provider.winrm_info @ssh_info[:username] ||= @machine.config.ssh.username @ssh_info[:password] ||= @machine.config.ssh.password @ssh_info end |
#upload(from, to) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/vagrant-azure/driver.rb', line 53 def upload(from, to) = { host_path: windows_path(from), guest_path: windows_path(to) }.merge(remote_credentials) script_path = local_script_path('upload_file.ps1') execute(script_path, ) end |