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 +4 -4
- data/README.md +2 -1
- data/example_box/README.md +2 -12
- data/lib/vagrant-vcenter/action/build_vm.rb +91 -40
- data/lib/vagrant-vcenter/action/inventory_check.rb +11 -28
- data/lib/vagrant-vcenter/config.rb +28 -1
- data/lib/vagrant-vcenter/plugin.rb +1 -1
- data/lib/vagrant-vcenter/version.rb +1 -1
- data/locales/en.yml +1 -1
- metadata +2 -4
- data/example_box/metadata.json +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c18c66e41d889b3cce4ec5c4b9231dd011536073
|
4
|
+
data.tar.gz: 3a6ac9901f9aef28ee9184557c73354da34d77e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
data/example_box/README.md
CHANGED
@@ -1,13 +1,3 @@
|
|
1
|
-
# vagrant-vcenter box specifications
|
1
|
+
# vagrant-vcenter box specifications
|
2
2
|
|
3
|
-
|
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
|
-
|
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
|
-
|
124
|
-
|
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
|
-
|
143
|
+
# Specify ip but no netmask
|
144
|
+
if network_spec[:ip] && !network_spec[:netmask]
|
145
|
+
fail Errors::WrongNetworkSpec
|
146
|
+
end
|
128
147
|
|
129
|
-
|
148
|
+
# specify netmask but no ip
|
149
|
+
if !network_spec[:ip] && network_spec[:netmask]
|
150
|
+
fail Errors::WrongNetworkSpec
|
151
|
+
end
|
130
152
|
|
131
|
-
|
153
|
+
global_ip_settings = RbVmomi::VIM.CustomizationGlobalIPSettings(
|
154
|
+
:dnsServerList => network_spec[:dns_server_list],
|
155
|
+
:dnsSuffixList => network_spec[:dns_suffix_list])
|
132
156
|
|
133
|
-
|
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
|
-
|
136
|
-
|
137
|
-
fail Errors::WrongNetworkSpec
|
169
|
+
nic_map = [RbVmomi::VIM.CustomizationAdapterMapping(
|
170
|
+
:adapter => adapter)]
|
138
171
|
end
|
139
172
|
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
-
|
146
|
-
|
147
|
-
|
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
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
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
|
-
|
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
|
-
|
167
|
-
|
216
|
+
nic_map = [RbVmomi::VIM.CustomizationAdapterMapping(
|
217
|
+
:adapter => adapter)]
|
168
218
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
219
|
+
cust_spec = RbVmomi::VIM.CustomizationSpec(
|
220
|
+
:globalIPSettings => global_ip_settings,
|
221
|
+
:identity => prep,
|
222
|
+
:nicSettingMap => nic_map)
|
173
223
|
|
174
|
-
|
175
|
-
|
224
|
+
spec.customization = cust_spec
|
225
|
+
end
|
176
226
|
|
177
|
-
|
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
|
-
|
55
|
-
|
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
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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
|
-
|
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
|
data/locales/en.yml
CHANGED
@@ -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
|
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.
|
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-
|
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
|
data/example_box/metadata.json
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"provider": "vagrant-vcenter"}
|