Class: VagrantPlugins::WinAzure::Provisioner::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-azure/provisioner/shell.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Shell

Returns a new instance of Shell.



11
12
13
14
# File 'lib/vagrant-azure/provisioner/shell.rb', line 11

def initialize(env)
  @env = env
  @provisioner = env[:provisioner]
end

Instance Attribute Details

#provisionerObject (readonly)

Returns the value of attribute provisioner.



9
10
11
# File 'lib/vagrant-azure/provisioner/shell.rb', line 9

def provisioner
  @provisioner
end

Instance Method Details

#provision_for_windowsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vagrant-azure/provisioner/shell.rb', line 16

def provision_for_windows
  arguments = ''
  arguments = "#{config.args}" if config.args

  with_windows_script_file do |path|
    guest_path = if File.extname(config.upload_path) == ''
      "#{config.upload_path}#{File.extname(path.to_s)}"
    else
      config.upload_path
    end

    @env[:ui].detail "Uploading [#{path}] to [#{guest_path}]"

    response = @env[:machine].provider.driver.upload(path, guest_path)

    command = "powershell.exe #{guest_path} #{arguments}"
    @env[:machine].provider.driver.run_remote_ps(
      command
    ) do |type, data|
      if type == :stdout || type == :stderr
        @env[:ui].detail data
      end
    end
  end
end