veewee 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/Gemfile +4 -0
  2. data/README.md +1 -1
  3. data/doc/definition.md +18 -0
  4. data/doc/kvm.md +28 -1
  5. data/doc/template.md +53 -2
  6. data/lib/veewee/command/fusion.rb +37 -3
  7. data/lib/veewee/command/vagrant/basebox.rb +2 -0
  8. data/lib/veewee/command/vagrant/winrm.rb +39 -0
  9. data/lib/veewee/command/vbox.rb +18 -0
  10. data/lib/veewee/definition.rb +13 -3
  11. data/lib/veewee/error.rb +3 -0
  12. data/lib/veewee/provider/core/box.rb +7 -0
  13. data/lib/veewee/provider/core/box/build.rb +34 -14
  14. data/lib/veewee/provider/core/box/copy.rb +17 -0
  15. data/lib/veewee/provider/core/box/exec.rb +31 -12
  16. data/lib/veewee/provider/core/box/floppy.rb +1 -0
  17. data/lib/veewee/provider/core/box/halt.rb +7 -3
  18. data/lib/veewee/provider/core/box/validate_tags.rb +8 -2
  19. data/lib/veewee/provider/core/box/wincp.rb +120 -0
  20. data/lib/veewee/provider/core/box/winrm.rb +59 -0
  21. data/lib/veewee/provider/core/helper/comm.rb +47 -0
  22. data/lib/veewee/provider/core/helper/web.rb +20 -9
  23. data/lib/veewee/provider/core/helper/winrm.rb +167 -0
  24. data/lib/veewee/provider/kvm/box/create.rb +59 -3
  25. data/lib/veewee/provider/kvm/provider.rb +6 -6
  26. data/lib/veewee/provider/parallels/box/helper/buildinfo.rb +1 -1
  27. data/lib/veewee/provider/virtualbox/box.rb +1 -0
  28. data/lib/veewee/provider/virtualbox/box/build.rb +4 -2
  29. data/lib/veewee/provider/virtualbox/box/create.rb +32 -12
  30. data/lib/veewee/provider/virtualbox/box/helper/buildinfo.rb +6 -3
  31. data/lib/veewee/provider/virtualbox/box/helper/create.rb +20 -5
  32. data/lib/veewee/provider/virtualbox/box/helper/winrm_options.rb +31 -0
  33. data/lib/veewee/provider/virtualbox/box/up.rb +33 -12
  34. data/lib/veewee/provider/virtualbox/box/winrm.rb +13 -0
  35. data/lib/veewee/provider/vmfusion/box.rb +2 -0
  36. data/lib/veewee/provider/vmfusion/box/add_share.rb +18 -0
  37. data/lib/veewee/provider/vmfusion/box/build.rb +3 -1
  38. data/lib/veewee/provider/vmfusion/box/create.rb +7 -2
  39. data/lib/veewee/provider/vmfusion/box/helper/buildinfo.rb +9 -6
  40. data/lib/veewee/provider/vmfusion/box/helper/ip.rb +1 -1
  41. data/lib/veewee/provider/vmfusion/box/helper/winrm_options.rb +21 -0
  42. data/lib/veewee/provider/vmfusion/box/template.rb +7 -3
  43. data/lib/veewee/provider/vmfusion/box/template.vmx.erb +6 -0
  44. data/lib/veewee/provider/vmfusion/box/winrm.rb +12 -0
  45. data/lib/veewee/provider/vmfusion/provider.rb +7 -1
  46. data/lib/veewee/version.rb +1 -1
  47. data/templates/CentOS-5.6-x86_64-netboot-packages/definition.rb +16 -0
  48. data/templates/CentOS-5.6-x86_64-netboot-packages/ks.cfg +47 -0
  49. data/templates/CentOS-5.6-x86_64-netboot-packages/postinstall.sh +61 -0
  50. data/templates/Debian-7.0-b3-amd64-netboot/base.sh +27 -0
  51. data/templates/Debian-7.0-b3-amd64-netboot/chef.sh +2 -0
  52. data/templates/Debian-7.0-b3-amd64-netboot/cleanup-virtualbox.sh +4 -0
  53. data/templates/Debian-7.0-b3-amd64-netboot/cleanup.sh +17 -0
  54. data/templates/Debian-7.0-b3-amd64-netboot/definition.rb +51 -0
  55. data/templates/Debian-7.0-b3-amd64-netboot/preseed.cfg +313 -0
  56. data/templates/Debian-7.0-b3-amd64-netboot/puppet.sh +2 -0
  57. data/templates/Debian-7.0-b3-amd64-netboot/ruby.sh +10 -0
  58. data/templates/Debian-7.0-b3-amd64-netboot/vagrant.sh +25 -0
  59. data/templates/Debian-7.0-b3-amd64-netboot/virtualbox.sh +13 -0
  60. data/templates/Debian-7.0-b3-amd64-netboot/zerodisk.sh +3 -0
  61. data/templates/Fedora-18-i386/definition.rb +17 -0
  62. data/templates/Fedora-18-i386/ks.cfg +75 -0
  63. data/templates/Fedora-18-i386/postinstall.sh +38 -0
  64. data/templates/Fedora-18-x86_64/definition.rb +17 -0
  65. data/templates/Fedora-18-x86_64/ks.cfg +75 -0
  66. data/templates/Fedora-18-x86_64/postinstall.sh +38 -0
  67. data/templates/OracleLinux-6.3-x86_64-DVD/base.sh +30 -0
  68. data/templates/OracleLinux-6.3-x86_64-DVD/chef.sh +3 -0
  69. data/templates/OracleLinux-6.3-x86_64-DVD/cleanup.sh +5 -0
  70. data/templates/OracleLinux-6.3-x86_64-DVD/definition.rb +40 -0
  71. data/templates/OracleLinux-6.3-x86_64-DVD/ks.cfg +42 -0
  72. data/templates/OracleLinux-6.3-x86_64-DVD/puppet.sh +12 -0
  73. data/templates/OracleLinux-6.3-x86_64-DVD/ruby.sh +3 -0
  74. data/templates/OracleLinux-6.3-x86_64-DVD/vagrant.sh +18 -0
  75. data/templates/OracleLinux-6.3-x86_64-DVD/virtualbox.sh +8 -0
  76. data/templates/OracleLinux-6.3-x86_64-DVD/zerodisk.sh +3 -0
  77. data/templates/funtoo-latest-x86_64/definition.rb +37 -0
  78. data/templates/funtoo-latest-x86_64/postinstall.sh +401 -0
  79. data/templates/openbsd50_amd64/definition.rb +3 -2
  80. data/templates/openbsd50_amd64/postinstall.sh +4 -4
  81. data/templates/openbsd50_i386/definition.rb +4 -4
  82. data/templates/openbsd52_amd64/README +28 -0
  83. data/templates/openbsd52_amd64/definition.rb +85 -0
  84. data/templates/openbsd52_amd64/postinstall.sh +81 -0
  85. data/templates/openbsd52_i386/README +28 -0
  86. data/templates/openbsd52_i386/definition.rb +85 -0
  87. data/templates/openbsd52_i386/postinstall.sh +81 -0
  88. data/templates/windows-2008R1-serverstandard-amd64/Autounattend.xml +6 -6
  89. data/templates/windows-2008R1-serverweb-amd64/install-winrm.bat +1 -1
  90. data/templates/windows-2008R2-serverstandard-amd64-winrm/Autounattend.xml +224 -0
  91. data/templates/windows-2008R2-serverstandard-amd64-winrm/README.md +87 -0
  92. data/templates/windows-2008R2-serverstandard-amd64-winrm/definition.rb +33 -0
  93. data/templates/windows-2008R2-serverstandard-amd64-winrm/install-chef.bat +2 -0
  94. data/templates/windows-2008R2-serverstandard-amd64-winrm/install-vbox.bat +4 -0
  95. data/templates/windows-2008R2-serverstandard-amd64-winrm/oracle-cert.cer +0 -0
  96. data/templates/windows-2008R2-serverstandard-amd64-winrm/postinstall.sh +74 -0
  97. data/templates/windows-7-enterprise-amd64-winrm/Autounattend.xml +227 -0
  98. data/templates/windows-7-enterprise-amd64-winrm/README.md +52 -0
  99. data/templates/windows-7-enterprise-amd64-winrm/definition.rb +27 -0
  100. data/templates/windows-7-enterprise-amd64-winrm/install-chef.bat +2 -0
  101. data/templates/windows-7-enterprise-amd64-winrm/install-fusion.bat +18 -0
  102. data/templates/windows-7-enterprise-amd64-winrm/install-puppet.bat +4 -0
  103. data/templates/windows-7-enterprise-amd64-winrm/install-vbox.bat +4 -0
  104. data/templates/windows-7-enterprise-amd64-winrm/oracle-cert.cer +0 -0
  105. data/templates/windows-7-enterprise-amd64-winrm/postinstall.bat +74 -0
  106. data/validation/veewee-windows.feature +34 -0
  107. data/veewee.gemspec +1 -1
  108. metadata +73 -7
@@ -9,13 +9,14 @@ module Veewee
9
9
 
10
10
  class FileServlet < WEBrick::HTTPServlet::AbstractServlet
11
11
 
12
- attr_reader :ui
12
+ attr_reader :ui, :threaded
13
13
 
14
- def initialize(server,localfile,ui)
14
+ def initialize(server,localfile,ui,threaded)
15
15
  super(server)
16
16
  @server=server
17
17
  @localfile=localfile
18
18
  @ui=ui
19
+ @threaded=threaded
19
20
  end
20
21
 
21
22
  def do_GET(request,response)
@@ -30,18 +31,27 @@ module Veewee
30
31
  ui.info "Serving file #{@localfile}"
31
32
  content
32
33
  end
33
- #If we shut too fast it might not get the complete file
34
- sleep 2
35
- @server.shutdown
34
+ if not @threaded
35
+ ui.info "Shutting down for #{@localfile}"
36
+ @server.shutdown
37
+ end
36
38
  end
37
39
  end
38
40
 
39
41
  end
40
42
  module Web
41
43
 
42
- def wait_for_http_request(filename,options={:timeout => 10, :web_dir => "", :port => 7125})
44
+ def wait_for_http_request(filename,options) # original blocking
45
+ s = server_for_http_request(filename,options)
46
+ s.start
47
+ end
43
48
 
49
+ def allow_for_http_request(filename,options) # start in new thread
50
+ s = server_for_http_request(filename,options.merge({:threaded => true}))
51
+ Thread.new { s.start }
52
+ end
44
53
 
54
+ def server_for_http_request(filename,options={:timeout => 10, :web_dir => "", :port => 7125, :threaded => false})
45
55
  # Calculate the OS equivalent of /dev/null , on windows this is NUL:
46
56
  # http://www.ruby-forum.com/topic/115472
47
57
  fn = test(?e, '/dev/null') ? '/dev/null' : 'NUL:'
@@ -55,14 +65,15 @@ module Veewee
55
65
  :Logger => webrick_logger,
56
66
  :AccessLog => webrick_logger
57
67
  )
58
- env.logger.debug("mounting file /#{filename}")
59
- s.mount("/#{filename}", Veewee::Provider::Core::Helper::Servlet::FileServlet,File.join(web_dir,filename),ui)
68
+ mount_filename = filename.start_with?('/') ? filename : "/#{filename}"
69
+ env.logger.debug("mounting file #{mount_filename}")
70
+ s.mount("#{mount_filename}", Veewee::Provider::Core::Helper::Servlet::FileServlet,File.join(web_dir,filename),ui,options[:threaded])
60
71
  trap("INT"){
61
72
  s.shutdown
62
73
  ui.info "Stopping webserver"
63
74
  exit
64
75
  }
65
- s.start
76
+ s
66
77
  end
67
78
 
68
79
  end #Class
@@ -0,0 +1,167 @@
1
+ module Veewee
2
+ module Provider
3
+ module Core
4
+ module Helper
5
+
6
+ class WinrmResult
7
+ attr_accessor :stdout
8
+ attr_accessor :stderr
9
+ attr_accessor :status
10
+
11
+ def initialize(stdout,stderr,status)
12
+ @stdout=stdout
13
+ @stderr=stderr
14
+ @status=status
15
+ end
16
+ end
17
+
18
+ module Winrm
19
+
20
+ require 'timeout'
21
+ require 'log4r'
22
+ require 'em-winrm'
23
+ require 'highline'
24
+
25
+ def winrm_up?(ip,options)
26
+ begin
27
+ if not @winrm_up
28
+ @httpcli = HTTPClient.new(:agent_name => 'Ruby WinRM Client')
29
+ @httpcli.receive_timeout = 10
30
+ @httpcli.set_auth(nil, options[:user], options[:pass])
31
+ @httpcli.get("http://#{ip}:#{options[:port]}/wsman")
32
+ @winrm_up = true
33
+ end
34
+ rescue HTTPClient::ReceiveTimeoutError,HTTPClient::ConnectTimeoutError
35
+ @winrm_up = false
36
+ end
37
+ end
38
+
39
+
40
+ def when_winrm_login_works(ip="127.0.0.1", options = {}, &block)
41
+
42
+ #options=winrm_options.merge(options.merge({:operation_timeout => 5}))
43
+ options=winrm_options.merge(options)
44
+ @login_works ||= {}
45
+ begin
46
+ Timeout::timeout(options[:timeout]) do
47
+ if @login_works[ip]
48
+ block.call(ip);
49
+ else
50
+ env.ui.info "Waiting for winrm login on #{ip} with user #{options[:user]} to windows on port => #{options[:port]} to work, timeout=#{options[:timeout]} sec"
51
+ until @connected do
52
+ begin
53
+ sleep 1
54
+ env.ui.info ".",{:new_line => false}
55
+ next if not winrm_up?(ip, options)
56
+ winrm_execute(ip,"hostname",options.merge({:progress => nil}))
57
+ @login_works[ip]=true
58
+ env.ui.info "\n"
59
+ block.call(ip);
60
+ env.ui.info ""
61
+ sleep 1
62
+ @connected = true
63
+ return true
64
+ rescue Exception => e
65
+ puts e.inspect
66
+ puts e.message
67
+ puts e.backtrace.inspect
68
+ sleep 5
69
+ end
70
+ end
71
+ end
72
+ end
73
+ rescue Timeout::Error
74
+ env.ui.error "Winrm timeout #{options[:timeout]} sec has been reached."
75
+ exit -1
76
+ rescue WinRM::WinRMHTTPTransportError => e
77
+ if e.message =~ /401/
78
+ env.ui.error "Unable to authenticate as '#{options[:user]}' with password '#{options[:pass]}'"
79
+ else
80
+ raise e
81
+ end
82
+ end
83
+ return false
84
+ end
85
+
86
+
87
+ def winrm_transfer_file(host,filename,destination = '.' , options = {})
88
+ options = winrm_options.merge(options.merge({:paranoid => false }))
89
+ # when_winrm_login_works
90
+
91
+ env.ui.info "FIXME: Transferring #{filename} to #{destination} "
92
+ # print these out while uploading:
93
+ env.ui.info ".",{:new_line => false}
94
+ # t::SSH.start( host,options[:user],options )
95
+ env.ui.info ""
96
+ end
97
+
98
+ def new_session(host,options)
99
+ opts = winrm_options.merge(options)
100
+ # create a session
101
+ begin
102
+ endpoint = "http://#{host}:#{opts[:port]}/wsman"
103
+ client = ::WinRM::WinRMWebService.new(endpoint, :plaintext, opts)
104
+ if opts[:operation_timeout]
105
+ client.set_timeout(opts[:operation_timeout])
106
+ end
107
+ rescue ::WinRM::WinRMAuthorizationError => error
108
+ raise ::WinRM::WinRMAuthorizationError.new("#{error.message}@#{host}")
109
+ end
110
+ client
111
+ end
112
+
113
+ def winrm_execute(host,command, options)
114
+
115
+ options = winrm_options.merge( # global default
116
+ { # function defaults
117
+ :exitcode => "0",
118
+ :progress => "on"
119
+ }.merge(
120
+ options # calling override
121
+ ))
122
+ stdout=""
123
+ stderr=""
124
+ status=-99999
125
+
126
+ @session ||= new_session(host, options)
127
+
128
+ env.ui.info "Executing winrm command: #{command}" if options[:progress]
129
+
130
+ @remote_id ||= @session.open_shell
131
+ command_id = @session.run_command(@remote_id, command)
132
+ output = @session.get_command_output(@remote_id, command_id) do |out,error|
133
+ if out
134
+ stdout += out
135
+ env.ui.info out,{:new_line => false} if options[:progress]
136
+ end
137
+ if error
138
+ stderr += error
139
+ env.ui.info error,{:new_line => false} if options[:progress]
140
+ end
141
+ end
142
+ status = output[:exitcode]
143
+ @session.close_shell(@remote_id)
144
+ @remote_id = nil
145
+ # env.ui.info "EXITCODE: #{status}" if status > 0
146
+ # @session.unbind
147
+ # FIXME: May want to look for a list of possible exitcodes
148
+ if (status.to_s != options[:exitcode] )
149
+ if (options[:exitcode]=="*")
150
+ #its a test so we don't need to worry
151
+ else
152
+ raise "Exitcode was not what we expected"
153
+ end
154
+
155
+ end
156
+
157
+ return Veewee::Provider::Core::Helper::WinrmResult.new(stdout,stderr,status)
158
+
159
+ end
160
+
161
+
162
+
163
+ end #Class
164
+ end #Module
165
+ end #Module
166
+ end #Module
167
+ end #Module
@@ -16,17 +16,73 @@ module Veewee
16
16
 
17
17
  def create_server(options)
18
18
  #memory_size,cpu_count, volume_size
19
- s=@connection.servers.create(
19
+ # verify some stuff before trying to create the server
20
+ kvm_options = definition.kvm[:vm_options][0]
21
+ # Create the "server"
22
+ attributes = {
20
23
  :name => name,
21
24
  :memory_size => definition.memory_size.to_i*1024,
22
25
  :cpus => definition.cpu_count.to_i,
23
26
  :volume_capacity => "#{definition.disk_size}M",
24
27
  :domain_type => options['use_emulation'] ? 'qemu': 'kvm',
25
- :network_interface_type => "network",
26
28
  :iso_file => definition.iso_file,
27
29
  :arch => definition.os_type_id.end_with?("_64") ? "x86_64" : "i686",
28
30
  :iso_dir => env.config.veewee.iso_dir
29
- )
31
+ }
32
+ # Check for network stuff (default, bridge)
33
+ check_network(kvm_options, attributes)
34
+ # Check for pool (storage)
35
+ check_pool(kvm_options, attributes)
36
+ s=@connection.servers.create(attributes)
37
+ end
38
+
39
+ # Check the network availability of the defined network for kvm
40
+ def check_network(options, attributes)
41
+ env.logger.info "Checking network"
42
+ if options.nil? or options.empty? or options["network_type"].nil? or options["network_type"] == "network"
43
+ check_default_network
44
+ attributes[:network_interface_type] = "network"
45
+ elsif options["network_type"] == "bridge"
46
+ options["network_bridge_name"].nil?
47
+ if options["network_bridge_name"].nil?
48
+ raise Veewee::Error, "You need to specify a 'network_bridge_name' if you plan to use 'bridge' as network type"
49
+ else
50
+ attributes[:network_interface_type] = "bridge"
51
+ attributes[:network_bridge_name] = "#{options["network_bridge_name"]}"
52
+ end
53
+ else
54
+ raise Veewee::Error, "You specified a 'network_type' that isn't known (#{options["network_type"]})"
55
+ end
56
+ end
57
+
58
+ def check_default_network
59
+ # Nothing specified, we check for default network
60
+ conn = ::Libvirt::open("qemu:///system")
61
+ networks=conn.list_networks
62
+ if networks.count < 1
63
+ raise Veewee::Error, "You need at least one (active) network defined or customize your definition. This needs to be available if you connect to qemu:///system."
64
+ end
65
+ end
66
+
67
+ # Check the given pool and append to attributes
68
+ # Note: volume_pool_name is not working in fog library version 1.7.0.
69
+ # This should be fixed in the next release.
70
+ def check_pool(options, attributes)
71
+ env.logger.info "Checking pool storage"
72
+ if not options.nil? and not options.empty? and not options["pool_name"].nil?
73
+ conn = ::Libvirt::open("qemu:///system")
74
+ # Checking if the pool exists and if it is active
75
+ begin
76
+ storage = conn.lookup_storage_pool_by_name(options["pool_name"])
77
+ rescue Libvirt::RetrieveError
78
+ raise Veewee::Error, "You've specified an non-existent storage pool (#{options["pool_name"]})"
79
+ end
80
+ if storage.active?
81
+ attributes[:volume_pool_name] = options["pool_name"]
82
+ else
83
+ raise Veewee::Error, "The storage pool '#{options["pool_name"]}' is not started. Start it and restart the creation process"
84
+ end
85
+ end
30
86
  end
31
87
 
32
88
  # Create the volume of a new vm
@@ -32,12 +32,12 @@ module Veewee
32
32
  raise Veewee::Error,"You need at least one (active) storage pool defined. This needs to be available if you connect to qemu:///system"
33
33
  end
34
34
 
35
- env.logger.info "Checking available networks"
36
- networks=conn.list_networks
37
- env.logger.info "Networks: #{networks.join(',')}"
38
- if networks.count < 1
39
- raise Veewee::Error,"You need at least one (active) network defined. This needs to be available if you connect to qemu:///system"
40
- end
35
+ #env.logger.info "Checking available networks"
36
+ #networks=conn.list_networks
37
+ #env.logger.info "Networks: #{networks.join(',')}"
38
+ #if networks.count < 1
39
+ # raise Veewee::Error,"You need at least one (active) network defined. This needs to be available if you connect to qemu:///system"
40
+ #end
41
41
 
42
42
  # http://www.libvirt.org/html/libvirt-libvirt.html#virGetVersion
43
43
  # format major * 1,000,000 + minor * 1,000 + release
@@ -36,7 +36,7 @@ module Veewee
36
36
 
37
37
  ui.info "About to transfer parallels tools iso buildinfo to the box #{name} - #{ip_address} - #{ssh_options}"
38
38
  iso_image=guest_iso_path
39
- self.scp(iso_image,File.basename(iso_image))
39
+ self.copy_to_box(iso_image,File.basename(iso_image))
40
40
  end
41
41
 
42
42
  end
@@ -14,6 +14,7 @@ require 'veewee/provider/virtualbox/box/helper/ip'
14
14
  require 'veewee/provider/virtualbox/box/helper/forwarding'
15
15
  require 'veewee/provider/virtualbox/box/helper/natinterface'
16
16
  require 'veewee/provider/virtualbox/box/helper/ssh_options'
17
+ require 'veewee/provider/virtualbox/box/helper/winrm_options'
17
18
  require 'veewee/provider/virtualbox/box/helper/guest_additions'
18
19
  require 'veewee/provider/virtualbox/box/helper/status'
19
20
  require 'veewee/provider/virtualbox/box/helper/version'
@@ -4,14 +4,16 @@ module Veewee
4
4
  module BoxCommand
5
5
 
6
6
  def build(options={})
7
- download_vbox_guest_additions_iso(options)
7
+
8
+ super(options)
8
9
 
9
10
  unless definition.floppy_files.nil?
10
11
  unless self.shell_exec("java -version").status == 0
11
12
  raise Veewee::Error,"This box contains floppyfiles, to create it you require to have java installed or have it in your path"
12
13
  end
13
14
  end
14
- super(options)
15
+
16
+ download_vbox_guest_additions_iso(options)
15
17
  end
16
18
 
17
19
  end
@@ -12,13 +12,6 @@ module Veewee
12
12
  raise Veewee::Error,"To create the vm '#{name}' the directory '#{box_directory}' needs to be empty. \nThis could be caused by an badly closed vm.\nRemove it manually before you proceed."
13
13
  end
14
14
 
15
- guessed_port=guess_free_port(definition.ssh_host_port.to_i,definition.ssh_host_port.to_i+40).to_s
16
- if guessed_port.to_s!=definition.ssh_host_port
17
- env.ui.warn "Changing ssh port from #{definition.ssh_host_port} to #{guessed_port}"
18
- definition.ssh_host_port=guessed_port.to_s
19
- end
20
-
21
-
22
15
  # Suppress those annoying virtualbox messages
23
16
  self.suppress_messages
24
17
 
@@ -36,19 +29,46 @@ module Veewee
36
29
  #Create a disk with the same name as the box_name
37
30
  self.create_disk
38
31
 
32
+ use_sata = definition.use_sata
33
+ if use_sata
34
+ disk_device_number = 0
35
+ isofile_ide_device_number = 0
36
+ else
37
+ disk_device_number = 0
38
+ isofile_ide_device_number = 1
39
+ end
40
+
39
41
  self.add_ide_controller
40
- self.attach_isofile
42
+ if use_sata
43
+ self.add_sata_controller
44
+ self.attach_disk_sata(disk_device_number)
45
+ else
46
+ self.attach_disk_ide(disk_device_number)
47
+ end
48
+ self.attach_isofile(isofile_ide_device_number)
41
49
  self.attach_guest_additions
42
50
 
43
- self.add_sata_controller
44
- self.attach_disk
45
-
46
51
  self.create_floppy("virtualfloppy.vfd")
47
52
 
48
53
  self.add_floppy_controller
49
54
  self.attach_floppy
50
55
 
51
- self.add_ssh_nat_mapping
56
+ if definition.winrm_user && definition.winrm_password # prefer winrm
57
+ env.ui.warn "Using winrm because winrm_user and winrm_password are both set"
58
+ guessed_port=guess_free_port(definition.winrm_host_port.to_i,definition.winrm_host_port.to_i+40).to_s
59
+ if guessed_port.to_s!=definition.winrm_host_port
60
+ env.ui.warn "Changing winrm port from #{definition.winrm_host_port} to #{guessed_port}"
61
+ definition.winrm_host_port=guessed_port.to_s
62
+ end
63
+ self.add_winrm_nat_mapping
64
+ else
65
+ guessed_port=guess_free_port(definition.ssh_host_port.to_i,definition.ssh_host_port.to_i+40).to_s
66
+ if guessed_port.to_s!=definition.ssh_host_port
67
+ env.ui.warn "Changing ssh port from #{definition.ssh_host_port} to #{guessed_port}"
68
+ definition.ssh_host_port=guessed_port.to_s
69
+ end
70
+ self.add_ssh_nat_mapping
71
+ end
52
72
 
53
73
  end
54
74
 
@@ -14,9 +14,12 @@ module Veewee
14
14
  #
15
15
  def transfer_buildinfo(options)
16
16
  super(options)
17
- iso_image="VBoxGuestAdditions_#{self.vboxga_version}.iso"
18
- env.logger.info "About to transfer virtualbox guest additions iso to the box #{name} - #{ip_address} - #{ssh_options}"
19
- self.scp("#{File.join(env.config.veewee.iso_dir,iso_image)}",File.basename(iso_image))
17
+ # with windows, we just use the mounted volume
18
+ if not (definition.winrm_user && definition.winrm_password)
19
+ iso_image="VBoxGuestAdditions_#{self.vboxga_version}.iso"
20
+ env.logger.info "About to transfer virtualbox guest additions iso to the box #{name} - #{ip_address} - #{ssh_options}"
21
+ self.copy_to_box("#{File.join(env.config.veewee.iso_dir,iso_image)}",File.basename(iso_image))
22
+ end
20
23
  end
21
24
 
22
25
  end