vagrant-vcenter 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7a088682faa4d0d1ba396bd4f8e4b4f514c88d26
4
- data.tar.gz: 46d87a3a7a167b7d359c081d14064591abc0c2ff
3
+ metadata.gz: c18c66e41d889b3cce4ec5c4b9231dd011536073
4
+ data.tar.gz: 3a6ac9901f9aef28ee9184557c73354da34d77e0
5
5
  SHA512:
6
- metadata.gz: f7a56ea70be027a21041e17206dc2dd48e0fc4971f3eed29e0de64679edfdde026ad0957c2fd30d72dc8bfe5d3b3552cd7c500b2b55a89a28ff50e3beac87e36
7
- data.tar.gz: e454c96bc57f2abc238c384af6da9c30c4911bf93b10fc3e27b726c4bb2dc210c1c98931a916cddb235195dc8e43dc3c22a839ebefea046f851b18fc5355f59a
6
+ metadata.gz: 6285240ba718d0588f6c50089feb1c601ae4d93c52263adfa4d3eb7f08d8354443de67650c1ccf3998cceeb0bb66d9716df7e0f074c3446b262bff8d7a441029
7
+ data.tar.gz: dceb922f02df844874eb30396c925fa1b06b1e100f64025dd124ef4a040e8dd2e72b3c30b575c2c29ee99bb647c6afe3dad95f73da36a27770f2225140640788
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  [Vagrant](http://www.vagrantup.com) provider for VMware vCenter®
2
2
  =============
3
3
 
4
- [Version 0.3.1](../../releases/tag/v0.3.1) has been released!
4
+ [Version 0.3.2](../../releases/tag/v0.3.2) has been released!
5
5
  -------------
6
6
 
7
7
  Please note that this software is still Alpha/Beta quality and is not recommended for production usage.
@@ -94,6 +94,7 @@ Vagrant.configure('2') do |config|
94
94
  override.folder_name = 'Vagrant/centos'
95
95
  when /precise/
96
96
  override.folder_name = 'Vagrant/ubuntu/precise'
97
+ override.enable_vm_customization = false
97
98
  end
98
99
  end
99
100
  node_config.nfs.functional = false
@@ -1,13 +1,3 @@
1
- # vagrant-vcenter box specifications [WIP]
1
+ # vagrant-vcenter box specifications
2
2
 
3
- *Note that vagrant-vcenter currently supports only single VM vApp boxes*
4
-
5
- BOX package should contain:
6
-
7
- - `metadata.json` -- Vagrant metadata file
8
- - `<boxname>.ovf` -- OVF descriptor of the vApp.
9
- - `<boxname>.mf` -- OVF manifest file containing file hashes.
10
- - `<boxname>-disk-<#>.vmdk` -- Associated VMDK files.
11
- - `Vagrantfile`-- vagrant-vcenter default Vagrantfile
12
-
13
- A [task is open](https://github.com/frapposelli/vagrant-vcenter/issues/12) for creating a veewee plugin to facilitate Box creation
3
+ [See this Wiki page for more information](https://github.com/gosddc/packer-post-processor-vagrant-vmware-ovf/wiki/vmware_ovf-Box-Format).
@@ -40,7 +40,14 @@ module VagrantPlugins
40
40
  # FIXME: Raise a correct exception
41
41
  computer = dc.find_compute_resource(
42
42
  config.computer_name) or fail 'Host not found'
43
- rp = computer.resourcePool
43
+
44
+ if config.resourcepool_name
45
+ rp = computer.resourcePool.resourcePool.find {
46
+ |f| f.name == config.resourcepool_name
47
+ }
48
+ else
49
+ rp = computer.resourcePool
50
+ end
44
51
 
45
52
  # FIXME: Raise a correct exception
46
53
  template = dc.find_vm(
@@ -120,61 +127,105 @@ module VagrantPlugins
120
127
  spec.config = config_spec
121
128
  end
122
129
 
123
- public_networks = env[:machine].config.vm.networks.select {
124
- |n| n[0].eql? :public_network
125
- }
130
+ if config.enable_vm_customization
131
+ public_networks = env[:machine].config.vm.networks.select {
132
+ |n| n[0].eql? :public_network
133
+ }
134
+
135
+ network_spec = public_networks.first[1] unless public_networks.empty?
136
+
137
+ @logger.debug("This is our network #{public_networks.inspect}")
138
+
139
+ if network_spec
140
+
141
+ # Check for sanity and validation of network parameters.
126
142
 
127
- network_spec = public_networks.first[1]
143
+ # Specify ip but no netmask
144
+ if network_spec[:ip] && !network_spec[:netmask]
145
+ fail Errors::WrongNetworkSpec
146
+ end
128
147
 
129
- @logger.debug("This is our network #{public_networks.inspect}")
148
+ # specify netmask but no ip
149
+ if !network_spec[:ip] && network_spec[:netmask]
150
+ fail Errors::WrongNetworkSpec
151
+ end
130
152
 
131
- if network_spec
153
+ global_ip_settings = RbVmomi::VIM.CustomizationGlobalIPSettings(
154
+ :dnsServerList => network_spec[:dns_server_list],
155
+ :dnsSuffixList => network_spec[:dns_suffix_list])
132
156
 
133
- # Check for sanity and validation of network parameters.
157
+ # if no ip and no netmask, let's default to dhcp
158
+ if !network_spec[:ip] && !network_spec[:netmask]
159
+ adapter = RbVmomi::VIM.CustomizationIPSettings(
160
+ :ip => RbVmomi::VIM.CustomizationDhcpIpGenerator())
161
+ else
162
+ adapter = RbVmomi::VIM.CustomizationIPSettings(
163
+ :gateway => [network_spec[:gateway]],
164
+ :ip => RbVmomi::VIM.CustomizationFixedIp(
165
+ :ipAddress => network_spec[:ip]),
166
+ :subnetMask => network_spec[:netmask])
167
+ end
134
168
 
135
- # Specify ip but no netmask
136
- if network_spec[:ip] && !network_spec[:netmask]
137
- fail Errors::WrongNetworkSpec
169
+ nic_map = [RbVmomi::VIM.CustomizationAdapterMapping(
170
+ :adapter => adapter)]
138
171
  end
139
172
 
140
- # specify netmask but no ip
141
- if !network_spec[:ip] && network_spec[:netmask]
142
- fail Errors::WrongNetworkSpec
173
+ if config.prep_type.downcase == 'linux'
174
+ prep = RbVmomi::VIM.CustomizationLinuxPrep(
175
+ :domain => env[:machine].name.to_s.sub(/^[^.]+\./, ''),
176
+ :hostName => RbVmomi::VIM.CustomizationFixedName(
177
+ :name => env[:machine].name.to_s.split('.')[0]))
178
+ elsif config.prep_type.downcase == 'windows'
179
+ prep = RbVmomi::VIM.CustomizationSysprep(
180
+ :guiUnattended => RbVmomi::VIM.CustomizationGuiUnattended(
181
+ :autoLogon => false,
182
+ :autoLogonCount => 0,
183
+ :timeZone => 004
184
+ ),
185
+ :identification => RbVmomi::VIM.CustomizationIdentification(),
186
+ :userData => RbVmomi::VIM.CustomizationUserData(
187
+ :computerName => RbVmomi::VIM.CustomizationFixedName(
188
+ :name => env[:machine].name.to_s.split('.')[0]),
189
+ :fullName => 'Vagrant',
190
+ :orgName => 'Vagrant',
191
+ :productId => 'XXXXX-XXXXX-XXXXX-XXXXX-XXXXX'
192
+ )
193
+ )
194
+ else
195
+ fail "specification type #{config.prep_type} not supported"
143
196
  end
144
197
 
145
- global_ip_settings = RbVmomi::VIM.CustomizationGlobalIPSettings(
146
- :dnsServerList => network_spec[:dns_server_list],
147
- :dnsSuffixList => network_spec[:dns_suffix_list])
198
+ if prep && network_spec
199
+ # If prep and network specification are present, let's do a full config
200
+ cust_spec = RbVmomi::VIM.CustomizationSpec(
201
+ :globalIPSettings => global_ip_settings,
202
+ :identity => prep,
203
+ :nicSettingMap => nic_map)
148
204
 
149
- prep = RbVmomi::VIM.CustomizationLinuxPrep(
150
- :domain => env[:machine].name.to_s.sub(/^[^.]+\./, ''),
151
- :hostName => RbVmomi::VIM.CustomizationFixedName(
152
- :name => env[:machine].name.to_s.split('.')[0]))
205
+ spec.customization = cust_spec
206
+
207
+ elsif prep && !network_spec
208
+ # If no network specifications, default to dhcp
209
+ global_ip_settings = RbVmomi::VIM.CustomizationGlobalIPSettings(
210
+ :dnsServerList => [],
211
+ :dnsSuffixList => [])
153
212
 
154
- # if no ip and no netmask, let's default to dhcp
155
- if !network_spec[:ip] && !network_spec[:netmask]
156
- adapter = RbVmomi::VIM.CustomizationIPSettings(
157
- :ip => RbVmomi::VIM.CustomizationDhcpIpGenerator())
158
- else
159
213
  adapter = RbVmomi::VIM.CustomizationIPSettings(
160
- :gateway => [network_spec[:gateway]],
161
- :ip => RbVmomi::VIM.CustomizationFixedIp(
162
- :ipAddress => network_spec[:ip]),
163
- :subnetMask => network_spec[:netmask])
164
- end
214
+ :ip => RbVmomi::VIM.CustomizationDhcpIpGenerator())
165
215
 
166
- nic_map = [RbVmomi::VIM.CustomizationAdapterMapping(
167
- :adapter => adapter)]
216
+ nic_map = [RbVmomi::VIM.CustomizationAdapterMapping(
217
+ :adapter => adapter)]
168
218
 
169
- cust_spec = RbVmomi::VIM.CustomizationSpec(
170
- :globalIPSettings => global_ip_settings,
171
- :identity => prep,
172
- :nicSettingMap => nic_map)
219
+ cust_spec = RbVmomi::VIM.CustomizationSpec(
220
+ :globalIPSettings => global_ip_settings,
221
+ :identity => prep,
222
+ :nicSettingMap => nic_map)
173
223
 
174
- spec.customization = cust_spec
175
- end
224
+ spec.customization = cust_spec
225
+ end
176
226
 
177
- @logger.debug("Spec: #{spec.pretty_inspect}")
227
+ @logger.debug("Spec: #{spec.pretty_inspect}")
228
+ end
178
229
 
179
230
  @logger.debug("disable_auto_vm_name: #{config.disable_auto_vm_name}")
180
231
 
@@ -37,9 +37,6 @@ module VagrantPlugins
37
37
 
38
38
  box_ovf = "file://#{box_dir}/#{box_file}.ovf"
39
39
 
40
- # Still relying on ruby-progressbar because report_progress basically
41
- # sucks.
42
-
43
40
  @logger.debug("OVF File: #{box_ovf}")
44
41
 
45
42
  env[:ui].info("Adding [#{box_name}]")
@@ -51,12 +48,11 @@ module VagrantPlugins
51
48
  root_vm_folder = dc.vmFolder
52
49
  vm_folder = root_vm_folder
53
50
  if config.template_folder_name.nil?
54
- vm_folder = root_vm_folder.traverse(config.template_folder_name,
55
- RbVmomi::VIM::Folder)
51
+ template_folder = root_vm_folder
52
+ else
53
+ template_folder = root_vm_folder.traverse!(
54
+ config.template_folder_name, RbVmomi::VIM::Folder)
56
55
  end
57
- template_folder = root_vm_folder.traverse!(
58
- config.template_folder_name,
59
- RbVmomi::VIM::Folder)
60
56
 
61
57
  template_name = box_name
62
58
 
@@ -109,8 +105,7 @@ module VagrantPlugins
109
105
  if config.template_folder_name.nil?
110
106
  box_to_search = box_name
111
107
  else
112
- box_to_search = config.template_folder_name +
113
- '/' + box_name
108
+ box_to_search = config.template_folder_name + '/' + box_name
114
109
  end
115
110
 
116
111
  @logger.debug("This is the box we're looking for: #{box_to_search}")
@@ -118,25 +113,13 @@ module VagrantPlugins
118
113
  config.template_id = dc.find_vm(box_to_search)
119
114
 
120
115
  if config.template_id.nil?
121
- env[:ui].warn("Template [#{box_name}] " +
122
- 'does not exist!')
123
-
124
- user_input = env[:ui].ask(
125
- "Would you like to upload the [#{box_name}]" +
126
- " box?\nChoice (yes/no): "
127
- )
128
-
129
- if user_input.downcase == 'yes' || user_input.downcase == 'y'
130
- env[:ui].info("Uploading [#{box_name}]...")
131
- vcenter_upload_box(env)
132
- else
133
- env[:ui].error('Template not uploaded, exiting...')
134
-
135
- # FIXME: wrong error message
136
- fail VagrantPlugins::VCenter::Errors::VCenterError,
137
- :message => 'Catalog not available, exiting...'
116
+ # Roll a dice to get a winner in the race.
117
+ sleep_time = rand * (3 - 1) + 1
118
+ @logger.debug("Sleeping #{sleep_time} to avoid race conditions.")
119
+ sleep(sleep_time)
138
120
 
139
- end
121
+ env[:ui].info("Uploading [#{box_name}]...")
122
+ vcenter_upload_box(env)
140
123
  else
141
124
  @logger.debug("Template found at #{box_to_search}")
142
125
  end
@@ -28,6 +28,11 @@ module VagrantPlugins
28
28
  # @return [String]
29
29
  attr_accessor :folder_name
30
30
 
31
+ # Resource Pool Name where the item will live
32
+ #
33
+ # @return [String]
34
+ attr_accessor :resourcepool_name
35
+
31
36
  # Catalog Name where the item resides
32
37
  #
33
38
  # @return [String]
@@ -75,6 +80,20 @@ module VagrantPlugins
75
80
  # @return [String]
76
81
  attr_accessor :vm_network_type
77
82
 
83
+ # Use prep and customization api in the building
84
+ # of the vm in vcenter
85
+ #
86
+ # Mostly this allows the static ip configuration
87
+ # of a vm
88
+ #
89
+ # @return [Bool]
90
+ attr_accessor :enable_vm_customization
91
+
92
+ # Type of the machine prep to use
93
+ #
94
+ # @return [String]
95
+ attr_accessor :prep_type
96
+
78
97
  # num cpu
79
98
  #
80
99
  # @return [Fixnum]
@@ -93,6 +112,11 @@ module VagrantPlugins
93
112
  attr_accessor :vcenter_cnx
94
113
  attr_accessor :template_id
95
114
 
115
+ def initialize
116
+ @prep_type = 'linux'
117
+ @enable_vm_customization = true
118
+ end
119
+
96
120
  def validate(machine)
97
121
  errors = _detected_errors
98
122
 
@@ -111,7 +135,10 @@ module VagrantPlugins
111
135
  I18n.t('vagrant_vcenter.config.computer_name') if computer_name.nil?
112
136
  errors <<
113
137
  I18n.t('vagrant_vcenter.config.network_name') if network_name.nil?
114
-
138
+ if enable_vm_customization
139
+ errors <<
140
+ I18n.t('vagrant_vcenter.config.no_prep_type') if prep_type.downcase != 'linux' && prep_type.downcase != 'windows'
141
+ end
115
142
  { 'vCenter Provider' => errors }
116
143
  end
117
144
  end
@@ -37,7 +37,7 @@ module VagrantPlugins
37
37
  Cap::PublicAddress
38
38
  end
39
39
 
40
- provider_capability(:vcenter, :winrm_info) do
40
+ provider_capability(:vcenter, :read_winrm_info) do
41
41
  require_relative 'cap/winrm_info'
42
42
  Cap::WinRM
43
43
  end
@@ -1,6 +1,6 @@
1
1
  module VagrantPlugins
2
2
  # Set version for vagrant-vcenter gem.
3
3
  module VCenter
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.2'
5
5
  end
6
6
  end
@@ -27,7 +27,7 @@ en:
27
27
  resourcepool_name: |-
28
28
  Configuration must specify a resource pool name
29
29
  no_prep_type: |-
30
- The only supported prep type is linux. hack away.
30
+ The only supported prep types are windows and linux.
31
31
  ipaddress: |-
32
32
  Configuration must specify a ipaddress
33
33
  gateway: |-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vcenter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabio Rapposelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vagrant-rbvmomi
@@ -121,8 +121,6 @@ files:
121
121
  - README.md
122
122
  - Rakefile
123
123
  - example_box/README.md
124
- - example_box/Vagrantfile
125
- - example_box/metadata.json
126
124
  - lib/vagrant-vcenter.rb
127
125
  - lib/vagrant-vcenter/action.rb
128
126
  - lib/vagrant-vcenter/action/announce_ssh_exec.rb
@@ -1 +0,0 @@
1
- {"provider": "vagrant-vcenter"}