vagrant-vsphere 0.17.0 → 0.18.0

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: b063bf190dceeafef58aa04ce867ebc9667d5c0b
4
- data.tar.gz: f43cc9c9d34d8a988166bd06aed7973fea7ea70c
3
+ metadata.gz: ca7707beee33ab9618da472c660a46a05e2ca8f4
4
+ data.tar.gz: bd28c6055786c007862865c0768f053d8309498c
5
5
  SHA512:
6
- metadata.gz: b947f9e482a26aebc7a723427aea0f2bb675738b4ea82114f92ac892026560dbe4e473d6d8de79d946a1a518e5d7953ca47f251d6b0c0f079080089dc2937db7
7
- data.tar.gz: fb835079c46f46143fdb719eeca089b5fe09dcd7255c442238081a1b0e293db2e08842a1839730554a8ba57c17cecf82aa026f5fcdaf49f80a29f6d298971710
6
+ metadata.gz: 7a83daf3b86d22e1346e463b82d5f54536663cca554d7b4dcd554fdb5cd85bfd114bb02e0a15b126b4f9c6cb5a5e0eba7304484bd050c2cf62ddc7900043e172
7
+ data.tar.gz: e5457be35238ac4eed9e1c95329ec9f699711d90c80432265dbce8a37cf288adaeb858c8edcbb8d21e1340fb2607f2b66f8fc804c7af0b51e323812f46732096
data/.bumpversion.cfg CHANGED
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.17.0
2
+ current_version = 0.18.0
3
3
  tag = true
4
4
  commit = true
5
5
 
data/README.md CHANGED
@@ -9,21 +9,21 @@ This provider is built on top of the [RbVmomi](https://github.com/vmware/rbvmomi
9
9
 
10
10
  ## Requirements
11
11
  * Vagrant 1.6.3+
12
- * VMware + vSphere API
12
+ * VMware with vSphere API
13
13
  * Ruby 1.9+
14
14
  * libxml2, libxml2-dev, libxslt, libxslt-dev
15
15
 
16
16
  ## Current Version
17
- **version: 0.17.0**
17
+ **version: 0.18.0**
18
18
 
19
- vagrant-vsphere (**version: 0.17.0**) is available from [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
19
+ vagrant-vsphere (**version: 0.18.0**) is available from [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
20
20
 
21
21
  ## Installation
22
22
 
23
23
  Install using standard Vagrant plugin method:
24
24
 
25
- ```
26
- $ vagrant plugin install vagrant-vsphere
25
+ ```bash
26
+ vagrant plugin install vagrant-vsphere
27
27
  ```
28
28
 
29
29
  This will install the plugin from RubyGems.org.
@@ -31,9 +31,9 @@ This will install the plugin from RubyGems.org.
31
31
  Alternatively, you can clone this repository and build the source with `gem build vSphere.gemspec`.
32
32
  After the gem is built, run the plugin install command from the build directory.
33
33
 
34
- ### Potential Intallation Problems
34
+ ### Potential Installation Problems
35
35
 
36
- The requirements for [Nokogiri](http://nokogiri.org/) must be installed before the plugin can be installed. See Nokogiri's [tutorial](http://nokogiri.org/tutorials/installing_nokogiri.html) for
36
+ The requirements for [Nokogiri](http://nokogiri.org/) must be installed before the plugin can be installed. See the [Nokogiri tutorial](http://nokogiri.org/tutorials/installing_nokogiri.html) for
37
37
  detailed instructions.
38
38
 
39
39
  The plugin forces use of Nokogiri ~> 1.5 to prevent conflicts with older versions of system libraries, specifically zlib.
@@ -43,8 +43,8 @@ The plugin forces use of Nokogiri ~> 1.5 to prevent conflicts with older version
43
43
  After installing the plugin, you must create a vSphere box. The example_box directory contains a metadata.json file
44
44
  that can be used to create a dummy box with the command:
45
45
 
46
- ```
47
- $ tar cvzf dummy.box ./metadata.json
46
+ ```bash
47
+ tar cvzf dummy.box ./metadata.json
48
48
  ```
49
49
 
50
50
  This can be installed using the standard Vagrant methods or specified in the Vagrantfile.
@@ -77,7 +77,8 @@ and the Vagrant [AWS provider](https://github.com/mitchellh/vagrant-aws/tree/mas
77
77
 
78
78
  ### Supported Commands
79
79
 
80
- Currently the only implemented actions are `up`, `halt`, `destroy`, and `ssh`.
80
+ Currently the only implemented actions are `up`, `halt`, `reload`, `destroy`,
81
+ and `ssh`.
81
82
 
82
83
  `up` supports provisioning of the new VM with the standard Vagrant provisioners.
83
84
 
@@ -97,7 +98,7 @@ This provider has the following settings, all are required unless noted:
97
98
  * `resource_pool_name` - the resource pool for the new VM. If not supplied, and cloning from a template, uses the root resource pool
98
99
  * `clone_from_vm` - _Optional_ use a virtual machine instead of a template as the source for the cloning operation
99
100
  * `template_name` - the VM or VM template to clone
100
- * `vm_base_path` - _Optional_ path to folder where new VM sould be created, if not specified template's parent folder will be used
101
+ * `vm_base_path` - _Optional_ path to folder where new VM should be created, if not specified template's parent folder will be used
101
102
  * `name` - _Optional_ name of the new VM, if missing the name will be auto generated
102
103
  * `customization_spec_name` - _Optional_ customization spec for the new VM
103
104
  * `data_store_name` - _Optional_ the datastore where the VM will be located
@@ -107,11 +108,34 @@ This provider has the following settings, all are required unless noted:
107
108
  * `vlan` - _Optional_ vlan to connect the first NIC to
108
109
  * `memory_mb` - _Optional_ Configure the amount of memory (in MB) for the new VM
109
110
  * `cpu_count` - _Optional_ Configure the number of CPUs for the new VM
111
+ * `mac` - _Optional_ Used to set the mac address of the new VM
110
112
 
111
113
  ### Cloning from a VM rather than a template
112
114
 
113
115
  To clone from an existing VM rather than a template, set `clone_from_vm` to true. If this value is set, `compute_resource_name` and `resource_pool_name` are not required.
114
116
 
117
+ ### Template_Name
118
+
119
+ * The template name includes the actual template name and the directory path containing the template.
120
+ * **For example:** if the template is a directory called **vagrant-templates** and the template is called **ubuntu-lucid-template** the `template_name` setting would be:
121
+ ```
122
+ vsphere.template_name = "vagrant-templates/ubuntu-lucid-template"
123
+ ```
124
+ ![Vagrant Vsphere Screenshot](https://raw.githubusercontent.com/nsidc/vagrant-vsphere/master/vsphere_screenshot.png)
125
+
126
+
127
+ ### VM_Base_Path
128
+
129
+ * The new vagrant VM will be created in the same directory as the template it originated from.
130
+ * To create the VM in a directory other than the one where the template was located, include the **vm_base_path** setting.
131
+ * **For example:** if the machines will be stored in a directory called **vagrant-machines** the `vm_base_path` would be:
132
+ ```
133
+ vsphere.vm_base_path = "vagrant-machines"
134
+ ```
135
+
136
+ ![Vagrant Vsphere Screenshot](https://raw.githubusercontent.com/nsidc/vagrant-vsphere/master/vsphere_screenshot.png)
137
+
138
+
115
139
  ### Setting a static IP address
116
140
 
117
141
  To set a static IP, add a private network to your vagrant file:
@@ -128,12 +152,67 @@ The name for the new VM will be automagically generated from the Vagrant machine
128
152
 
129
153
  This is useful if running Vagrant from multiple directories or if multiple machines are defined in the Vagrantfile.
130
154
 
155
+ ### Setting the MAC address
156
+
157
+ To set a static MAC address, add a `vsphere.mac` to your `Vagrantfile`:
158
+
159
+ ```ruby
160
+ vsphere.mac = '00:50:56:XX:YY:ZZ'
161
+ ```
162
+
163
+ Take care to avoid using invalid or duplicate VMware MAC addresses, as this can
164
+ easily break networking.
165
+
166
+ ## Example Usage
167
+
168
+ ### FILE: Vagrantfile
169
+ ```ruby
170
+ VAGRANT_INSTANCE_NAME = "vagrant-vsphere"
171
+
172
+ Vagrant.configure("2") do |config|
173
+ config.vm.box = 'vsphere'
174
+ config.vm.box_url = 'https://vagrantcloud.com/ssx/boxes/vsphere-dummy/versions/0.0.1/providers/vsphere.box'
175
+
176
+ config.vm.hostname = VAGRANT_INSTANCE_NAME
177
+ config.vm.define VAGRANT_INSTANCE_NAME do |d|
178
+ end
179
+
180
+ config.vm.provider :vsphere do |vsphere|
181
+ vsphere.host = 'vsphere.local'
182
+ vsphere.name = VAGRANT_INSTANCE_NAME
183
+ vsphere.compute_resource_name = 'vagrant01.vsphere.local'
184
+ vsphere.resource_pool_name = 'vagrant'
185
+ vsphere.template_name = 'vagrant-templates/ubuntu14041'
186
+ vsphere.vm_base_path = "vagrant-machines"
187
+
188
+ vsphere.user = 'vagrant-user@vsphere'
189
+ vsphere.password = '***************'
190
+ vsphere.insecure = true
191
+ end
192
+ end
193
+ ```
194
+
195
+ ### Vagrant Up
196
+ ```bash
197
+ vagrant up --provider=vsphere
198
+ ```
199
+
200
+ ### Vagrant SSH
201
+ ```bash
202
+ vagrant ssh
203
+ ```
204
+
205
+ ### Vagrant Destroy
206
+ ```bash
207
+ vagrant destroy
208
+ ```
209
+
131
210
  ## Version History
132
211
  * 0.0.1
133
212
  * Initial release
134
213
  * 0.1.0
135
214
  * Add folder syncing with guest OS
136
- * Add provisoning
215
+ * Add provisioning
137
216
  * 0.2.0
138
217
  * Merge halt action from [catharsis](https://github.com/catharsis)
139
218
  * 0.3.0
@@ -182,7 +261,9 @@ This is useful if running Vagrant from multiple directories or if multiple machi
182
261
  * Instruct vagrant to set the guest hostname according to Vagrantfile [#69 ddub:set-hostname](https://github.com/nsidc/vagrant-vsphere/pull/69)
183
262
  * 0.10.0
184
263
  * new optional parameter to clone into custom folder in vSphere [#73 mikola-spb:vm-base-path](https://github.com/nsidc/vagrant-vsphere/pull/73)
185
- * follows semvar better, this adds functionality in a backwards compatible way, so bumps the minor. 0.9.0, should have been a major version.
264
+ * follows [semver](http://semver.org/) better, this adds functionality in a
265
+ backwards compatible way, so bumps the minor. 0.9.0, should have been a
266
+ major version.
186
267
  * 0.11.0
187
268
  * Create the VM target folder if it doesn't exist #76 marnovdm:feature/create_vm_folder.
188
269
  * 0.12.0
@@ -210,6 +291,12 @@ This is useful if running Vagrant from multiple directories or if multiple machi
210
291
  * Fix compatibility with Vagrant 1.7 to use vSphere connection info from a base
211
292
  box
212
293
  [#111 mkuzmin:get-state](https://github.com/nsidc/vagrant-vsphere/pull/111).
294
+ * 0.18.0
295
+ * Gracefully power off the VM with `vagrant halt`, and shutdown before
296
+ deleting the VM with `vagrant destroy`
297
+ [#104 clintoncwolfe:shutdown-guest-on-halt](https://github.com/nsidc/vagrant-vsphere/pull/104).
298
+ * Add configuration option `mac` to specify a MAC address for the VM
299
+ [#108 dataplayer:master](https://github.com/nsidc/vagrant-vsphere/pull/108).
213
300
 
214
301
  ## Versioning
215
302
 
@@ -11,10 +11,14 @@ module VagrantPlugins
11
11
  Vagrant::Action::Builder.new.tap do |b|
12
12
  b.use ConfigValidate
13
13
  b.use ConnectVSphere
14
+
14
15
  b.use Call, IsRunning do |env, b2|
15
16
  if [:result]
16
- b2.use PowerOff
17
- next
17
+ b2.use Call, GracefulHalt, :poweroff, :running do |env, b3|
18
+ if !env[:result]
19
+ b3.use PowerOff
20
+ end
21
+ end
18
22
  end
19
23
  end
20
24
  b.use Destroy
@@ -126,7 +130,11 @@ module VagrantPlugins
126
130
  next
127
131
  end
128
132
 
129
- b3.use PowerOff
133
+ b3.use Call, GracefulHalt, :poweroff, :running do |env, b4|
134
+ if !env[:result]
135
+ b4.use PowerOff
136
+ end
137
+ end
130
138
  end
131
139
  end
132
140
  b.use CloseVSphere
@@ -32,6 +32,7 @@ module VagrantPlugins
32
32
  customization_info = get_customization_spec_info_by_name connection, machine
33
33
 
34
34
  spec[:customization] = get_customization_spec(machine, customization_info) unless customization_info.nil?
35
+ add_custom_mac(template, spec, config.mac) unless config.mac.nil?
35
36
  add_custom_vlan(template, dc, spec, config.vlan) unless config.vlan.nil?
36
37
  add_custom_memory(spec, config.memory_mb) unless config.memory_mb.nil?
37
38
  add_custom_cpu(spec, config.cpu_count) unless config.cpu_count.nil?
@@ -139,20 +140,37 @@ module VagrantPlugins
139
140
  end
140
141
  end
141
142
 
143
+ def modify_network_card(template, spec)
144
+ spec[:config][:deviceChange] ||= []
145
+ @card ||= template.config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).first
146
+
147
+ fail Errors::VSphereError, :missing_network_card if @card.nil?
148
+
149
+ yield(@card)
150
+
151
+ dev_spec = RbVmomi::VIM.VirtualDeviceConfigSpec(:device => @card, :operation => "edit")
152
+ spec[:config][:deviceChange].push dev_spec
153
+ spec[:config][:deviceChange].uniq!
154
+ end
155
+
156
+ def add_custom_mac(template, spec, mac)
157
+ modify_network_card(template, spec) do |card|
158
+ card.macAddress = mac
159
+ end
160
+ end
161
+
142
162
  def add_custom_vlan(template, dc, spec, vlan)
143
- spec[:config][:deviceChange] = []
144
163
  network = get_network_by_name(dc, vlan)
145
- config = template.config
146
- card = config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).first or fail Errors::VSphereError, :missing_network_card
147
- begin
148
- switch_port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(:switchUuid => network.config.distributedVirtualSwitch.uuid, :portgroupKey => network.key)
149
- card.backing.port = switch_port
150
- rescue
151
- # not connected to a distibuted switch?
152
- card.backing.deviceName = network.name
164
+
165
+ modify_network_card(template, spec) do |card|
166
+ begin
167
+ switch_port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(:switchUuid => network.config.distributedVirtualSwitch.uuid, :portgroupKey => network.key)
168
+ card.backing.port = switch_port
169
+ rescue
170
+ # not connected to a distibuted switch?
171
+ card.backing = RbVmomi::VIM::VirtualEthernetCardNetworkBackingInfo(:network => network, :deviceName => network.name)
172
+ end
153
173
  end
154
- dev_spec = RbVmomi::VIM.VirtualDeviceConfigSpec(:device => card, :operation => "edit")
155
- spec[:config][:deviceChange].push dev_spec
156
174
  end
157
175
 
158
176
  def add_custom_memory(spec, memory_mb)
@@ -20,6 +20,7 @@ module VagrantPlugins
20
20
  attr_accessor :proxy_host
21
21
  attr_accessor :proxy_port
22
22
  attr_accessor :vlan
23
+ attr_accessor :mac
23
24
  attr_accessor :memory_mb
24
25
  attr_accessor :cpu_count
25
26
 
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VSphere
3
- VERSION = '0.17.0'
3
+ VERSION = '0.18.0'
4
4
  end
5
5
  end
data/spec/action_spec.rb CHANGED
@@ -69,12 +69,17 @@ describe VagrantPlugins::VSphere::Action do
69
69
  end
70
70
 
71
71
  describe 'halt' do
72
- it 'should power off the VM' do
73
- @machine.state.stub(:id).and_return(:running)
72
+ after :each do
73
+ run :halt
74
+ end
74
75
 
75
- VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
76
+ it 'should connect to vSphere' do
77
+ VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
78
+ end
76
79
 
77
- run :halt
80
+ it 'should gracefully power off the VM' do
81
+ @machine.state.stub(:id).and_return(:running)
82
+ VagrantPlugins::VSphere::Action::GracefulHalt.any_instance.should_receive(:call)
78
83
  end
79
84
  end
80
85
 
@@ -125,10 +130,10 @@ describe VagrantPlugins::VSphere::Action do
125
130
  run :reload
126
131
  end
127
132
 
128
- it 'should power off the VM' do
133
+ it 'should gracefully power off the VM' do
129
134
  @machine.state.stub(:id).and_return(:running)
130
135
 
131
- VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
136
+ VagrantPlugins::VSphere::Action::GracefulHalt.any_instance.should_receive(:call)
132
137
  end
133
138
 
134
139
  it 'should connect to vSphere' do
data/spec/spec_helper.rb CHANGED
@@ -55,7 +55,8 @@ RSpec.configure do |config|
55
55
  :proxy_port => nil,
56
56
  :vlan => nil,
57
57
  :memory_mb => nil,
58
- :cpu_count => nil)
58
+ :cpu_count => nil,
59
+ :mac => nil)
59
60
  vm_config = double(
60
61
  :vm => double('config_vm',
61
62
  :box => nil,
@@ -63,7 +64,8 @@ RSpec.configure do |config|
63
64
  :provisioners => [],
64
65
  :hostname => nil,
65
66
  :communicator => nil,
66
- :networks => [[:private_network, {:ip => '0.0.0.0'}]]),
67
+ :networks => [[:private_network, {:ip => '0.0.0.0'}]],
68
+ :graceful_halt_timeout => 0.1),
67
69
  :validate => []
68
70
  )
69
71
  @app = double 'app', :call => true
@@ -75,12 +77,13 @@ RSpec.configure do |config|
75
77
  :ssh_info => {},
76
78
  :data_dir => Pathname.new(''),
77
79
  :id => nil,
78
- :id= => nil
80
+ :id= => nil,
81
+ :guest => double('guest', :capability => nil)
79
82
 
80
83
 
81
84
  @env = {
82
85
  :machine => @machine,
83
- :ui => double('ui', :info => nil)
86
+ :ui => double('ui', :info => nil, :output => nil)
84
87
  }
85
88
 
86
89
  @vm = double('vm',
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Grauch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-30 00:00:00.000000000 Z
11
+ date: 2014-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -157,6 +157,7 @@ files:
157
157
  - spec/power_off_spec.rb
158
158
  - spec/spec_helper.rb
159
159
  - vSphere.gemspec
160
+ - vsphere_screenshot.png
160
161
  homepage: ''
161
162
  licenses:
162
163
  - MIT