vagrant-vsphere 0.16.0 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.bumpversion.cfg +1 -1
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/README.md +45 -4
- data/lib/vSphere/action.rb +15 -0
- data/lib/vSphere/action/clone.rb +5 -0
- data/lib/vSphere/action/message_not_created.rb +2 -2
- data/lib/vSphere/config.rb +5 -0
- data/lib/vSphere/version.rb +1 -1
- data/spec/action_spec.rb +42 -2
- data/spec/clone_spec.rb +12 -0
- data/spec/spec_helper.rb +2 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b063bf190dceeafef58aa04ce867ebc9667d5c0b
|
4
|
+
data.tar.gz: f43cc9c9d34d8a988166bd06aed7973fea7ea70c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b947f9e482a26aebc7a723427aea0f2bb675738b4ea82114f92ac892026560dbe4e473d6d8de79d946a1a518e5d7953ca47f251d6b0c0f079080089dc2937db7
|
7
|
+
data.tar.gz: fb835079c46f46143fdb719eeca089b5fe09dcd7255c442238081a1b0e293db2e08842a1839730554a8ba57c17cecf82aa026f5fcdaf49f80a29f6d298971710
|
data/.bumpversion.cfg
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/nsidc/vagrant-vsphere.svg?branch=master)](https://travis-ci.org/nsidc/vagrant-vsphere)
|
2
|
+
|
1
3
|
# Vagrant vSphere Provider
|
2
4
|
|
3
5
|
This is a [Vagrant](http://www.vagrantup.com) 1.6.3+ plugin that adds a [vSphere](http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fright-pane.html)
|
@@ -12,9 +14,9 @@ This provider is built on top of the [RbVmomi](https://github.com/vmware/rbvmomi
|
|
12
14
|
* libxml2, libxml2-dev, libxslt, libxslt-dev
|
13
15
|
|
14
16
|
## Current Version
|
15
|
-
**version: 0.
|
17
|
+
**version: 0.17.0**
|
16
18
|
|
17
|
-
vagrant-vsphere (**version: 0.
|
19
|
+
vagrant-vsphere (**version: 0.17.0**) is available from [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
|
18
20
|
|
19
21
|
## Installation
|
20
22
|
|
@@ -87,7 +89,9 @@ This provider has the following settings, all are required unless noted:
|
|
87
89
|
* `host` - IP or name for the vSphere API
|
88
90
|
* `insecure` - _Optional_ verify SSL certificate from the host
|
89
91
|
* `user` - user name for connecting to vSphere
|
90
|
-
* `password` - password
|
92
|
+
* `password` - password for connecting to vSphere. If no value is given, or the
|
93
|
+
value is set to `:ask`, the user will be prompted to enter the password on
|
94
|
+
each invocation.
|
91
95
|
* `data_center_name` - _Optional_ datacenter containing the computed resource, the template and where the new VM will be created, if not specified the first datacenter found will be used
|
92
96
|
* `compute_resource_name` - _Required if cloning from template_ the name of the host containing the resource pool for the new VM
|
93
97
|
* `resource_pool_name` - the resource pool for the new VM. If not supplied, and cloning from a template, uses the root resource pool
|
@@ -102,6 +106,7 @@ This provider has the following settings, all are required unless noted:
|
|
102
106
|
* `proxy_port` - _Optional_ proxy port number for connecting to vSphere via proxy
|
103
107
|
* `vlan` - _Optional_ vlan to connect the first NIC to
|
104
108
|
* `memory_mb` - _Optional_ Configure the amount of memory (in MB) for the new VM
|
109
|
+
* `cpu_count` - _Optional_ Configure the number of CPUs for the new VM
|
105
110
|
|
106
111
|
### Cloning from a VM rather than a template
|
107
112
|
|
@@ -194,7 +199,17 @@ This is useful if running Vagrant from multiple directories or if multiple machi
|
|
194
199
|
* If the VM is powered off, it is just destroyed.
|
195
200
|
* If the VM is suspended, it is powered on, then powered off, then destroyed.
|
196
201
|
* 0.16.0 Add ability to configure amount of memory the new cloned VM will have [#94 rylarson:add-memory-configuration](https://github.com/nsidc/vagrant-vsphere/pull/94).
|
197
|
-
|
202
|
+
* 0.17.0
|
203
|
+
* Add ability to configure the CPU Count
|
204
|
+
[#96 rylarson:add-cpu-configuration](https://github.com/nsidc/vagrant-vsphere/pull/96).
|
205
|
+
* Prompt the user to enter a password if none is given, or the configuration
|
206
|
+
value is set to `:ask`
|
207
|
+
[#97 topmedia:password-prompt](https://github.com/nsidc/vagrant-vsphere/pull/97).
|
208
|
+
* Add support for `vagrant reload`
|
209
|
+
[#105 clintoncwolfe:add-reload-action](https://github.com/nsidc/vagrant-vsphere/pull/105).
|
210
|
+
* Fix compatibility with Vagrant 1.7 to use vSphere connection info from a base
|
211
|
+
box
|
212
|
+
[#111 mkuzmin:get-state](https://github.com/nsidc/vagrant-vsphere/pull/111).
|
198
213
|
|
199
214
|
## Versioning
|
200
215
|
|
@@ -216,7 +231,33 @@ If you want a quick merge, write a spec that fails before your changes are appli
|
|
216
231
|
|
217
232
|
If you don't have rake installed, first install [bundler](http://bundler.io/) and run `bundle install`.
|
218
233
|
|
234
|
+
### Development Without Building the Plugin
|
235
|
+
|
236
|
+
To test your changes when developing the plugin, you have two main
|
237
|
+
options. First, you can build and install the plugin from source every time you
|
238
|
+
make a change:
|
239
|
+
|
240
|
+
1. Make changes
|
241
|
+
2. `rake build`
|
242
|
+
3. `vagrant plugin install ./pkg/vagrant-vsphere-$VERSION.gem`
|
243
|
+
4. `vagrant up --provider=vsphere`
|
244
|
+
|
245
|
+
Second, you can use Bundler and the Vagrant gem to execute vagrant commands,
|
246
|
+
saving time as you never have to wait for the plugin to build and install:
|
247
|
+
|
248
|
+
1. Make changes
|
249
|
+
2. `bundle exec vagrant up --provider=vsphere`
|
250
|
+
|
251
|
+
This method uses the version of Vagrant specified in
|
252
|
+
[`Gemfile`](https://github.com/nsidc/vagrant-vsphere/blob/master/Gemfile). It
|
253
|
+
will also cause Bundler and Vagrant to output warnings every time you run
|
254
|
+
`bundle exec vagrant`, because `Gemfile` lists **vagrant-vsphere** twice (once
|
255
|
+
with `gemspec` and another time in the `group :plugins` block), and Vagrant
|
256
|
+
prefers to be run from the official installer rather than through the gem.
|
219
257
|
|
258
|
+
Despite those warning messages, this is the
|
259
|
+
[officially recommended](https://docs.vagrantup.com/v2/plugins/development-basics.html)
|
260
|
+
method for Vagrant plugin development.
|
220
261
|
|
221
262
|
## License
|
222
263
|
|
data/lib/vSphere/action.rb
CHANGED
@@ -133,9 +133,24 @@ module VagrantPlugins
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
+
def self.action_reload
|
137
|
+
Vagrant::Action::Builder.new.tap do |b|
|
138
|
+
b.use ConnectVSphere
|
139
|
+
b.use Call, IsCreated do |env, b2|
|
140
|
+
if !env[:result]
|
141
|
+
b2.use MessageNotCreated
|
142
|
+
next
|
143
|
+
end
|
144
|
+
b2.use action_halt
|
145
|
+
b2.use action_up
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
136
150
|
#vSphere specific actions
|
137
151
|
def self.action_get_state
|
138
152
|
Vagrant::Action::Builder.new.tap do |b|
|
153
|
+
b.use HandleBox
|
139
154
|
b.use ConfigValidate
|
140
155
|
b.use ConnectVSphere
|
141
156
|
b.use GetState
|
data/lib/vSphere/action/clone.rb
CHANGED
@@ -34,6 +34,7 @@ module VagrantPlugins
|
|
34
34
|
spec[:customization] = get_customization_spec(machine, customization_info) unless customization_info.nil?
|
35
35
|
add_custom_vlan(template, dc, spec, config.vlan) unless config.vlan.nil?
|
36
36
|
add_custom_memory(spec, config.memory_mb) unless config.memory_mb.nil?
|
37
|
+
add_custom_cpu(spec, config.cpu_count) unless config.cpu_count.nil?
|
37
38
|
|
38
39
|
env[:ui].info I18n.t('vsphere.creating_cloned_vm')
|
39
40
|
env[:ui].info " -- #{config.clone_from_vm ? "Source" : "Template"} VM: #{template.pretty_path}"
|
@@ -157,6 +158,10 @@ module VagrantPlugins
|
|
157
158
|
def add_custom_memory(spec, memory_mb)
|
158
159
|
spec[:config][:memoryMB] = Integer(memory_mb)
|
159
160
|
end
|
161
|
+
|
162
|
+
def add_custom_cpu(spec, cpu_count)
|
163
|
+
spec[:config][:numCPUs] = Integer(cpu_count)
|
164
|
+
end
|
160
165
|
end
|
161
166
|
end
|
162
167
|
end
|
data/lib/vSphere/config.rb
CHANGED
@@ -21,10 +21,15 @@ module VagrantPlugins
|
|
21
21
|
attr_accessor :proxy_port
|
22
22
|
attr_accessor :vlan
|
23
23
|
attr_accessor :memory_mb
|
24
|
+
attr_accessor :cpu_count
|
24
25
|
|
25
26
|
def validate(machine)
|
26
27
|
errors = _detected_errors
|
27
28
|
|
29
|
+
if password == :ask || password.nil?
|
30
|
+
self.password = machine.ui.ask("vSphere Password (will be hidden): ", echo: false)
|
31
|
+
end
|
32
|
+
|
28
33
|
# TODO: add blank?
|
29
34
|
errors << I18n.t('vsphere.config.host') if host.nil?
|
30
35
|
errors << I18n.t('vsphere.config.user') if user.nil?
|
data/lib/vSphere/version.rb
CHANGED
data/spec/action_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe VagrantPlugins::VSphere::Action do
|
|
5
5
|
def run(action)
|
6
6
|
Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
before :each do
|
10
10
|
@machine.stub(:id).and_return(EXISTING_UUID)
|
11
11
|
end
|
@@ -71,7 +71,7 @@ describe VagrantPlugins::VSphere::Action do
|
|
71
71
|
describe 'halt' do
|
72
72
|
it 'should power off the VM' do
|
73
73
|
@machine.state.stub(:id).and_return(:running)
|
74
|
-
|
74
|
+
|
75
75
|
VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
|
76
76
|
|
77
77
|
run :halt
|
@@ -94,6 +94,12 @@ describe VagrantPlugins::VSphere::Action do
|
|
94
94
|
|
95
95
|
run_get_state
|
96
96
|
end
|
97
|
+
|
98
|
+
it 'should handle the values in a base vagrant box' do
|
99
|
+
Vagrant::Action::Builtin::HandleBox.any_instance.should_receive(:call)
|
100
|
+
|
101
|
+
run_get_state
|
102
|
+
end
|
97
103
|
end
|
98
104
|
|
99
105
|
describe 'get ssh info' do
|
@@ -113,4 +119,38 @@ describe VagrantPlugins::VSphere::Action do
|
|
113
119
|
run_get_ssh_info
|
114
120
|
end
|
115
121
|
end
|
122
|
+
|
123
|
+
describe 'reload' do
|
124
|
+
after :each do
|
125
|
+
run :reload
|
126
|
+
end
|
127
|
+
|
128
|
+
it 'should power off the VM' do
|
129
|
+
@machine.state.stub(:id).and_return(:running)
|
130
|
+
|
131
|
+
VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should connect to vSphere' do
|
135
|
+
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should check if the VM exits' do
|
139
|
+
VagrantPlugins::VSphere::Action::IsCreated.any_instance.should_receive(:call)
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should not create the VM when the VM does already not exist' do
|
143
|
+
@machine.state.stub(:id).and_return(:not_created)
|
144
|
+
|
145
|
+
VagrantPlugins::VSphere::Action::Clone.any_instance.should_not_receive(:call)
|
146
|
+
VagrantPlugins::VSphere::Action::MessageNotCreated.any_instance.should_receive(:call)
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should not create the VM when the VM already exists' do
|
150
|
+
@machine.state.stub(:id).and_return(:running)
|
151
|
+
|
152
|
+
VagrantPlugins::VSphere::Action::Clone.any_instance.should_not_receive(:call)
|
153
|
+
VagrantPlugins::VSphere::Action::MessageAlreadyCreated.any_instance.should_receive(:call)
|
154
|
+
end
|
155
|
+
end
|
116
156
|
end
|
data/spec/clone_spec.rb
CHANGED
@@ -73,6 +73,18 @@ describe VagrantPlugins::VSphere::Action::Clone do
|
|
73
73
|
})
|
74
74
|
end
|
75
75
|
|
76
|
+
|
77
|
+
it 'should create a CloneVM spec with configured number of cpus' do
|
78
|
+
@machine.provider_config.stub(:cpu_count).and_return(4)
|
79
|
+
call
|
80
|
+
expect(@template).to have_received(:CloneVM_Task).with({
|
81
|
+
:folder => @data_center,
|
82
|
+
:name => NAME,
|
83
|
+
:spec => {:location => {:pool => @child_resource_pool},
|
84
|
+
:config => RbVmomi::VIM.VirtualMachineConfigSpec(:numCPUs => 4) },
|
85
|
+
})
|
86
|
+
end
|
87
|
+
|
76
88
|
it 'should set static IP when given config spec' do
|
77
89
|
@machine.provider_config.stub(:customization_spec_name).and_return('spec')
|
78
90
|
call
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.17.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-
|
11
|
+
date: 2014-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -117,6 +117,7 @@ extra_rdoc_files: []
|
|
117
117
|
files:
|
118
118
|
- .bumpversion.cfg
|
119
119
|
- .gitignore
|
120
|
+
- .travis.yml
|
120
121
|
- Gemfile
|
121
122
|
- LICENSE.txt
|
122
123
|
- README.md
|
@@ -176,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
177
|
version: '0'
|
177
178
|
requirements: []
|
178
179
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.
|
180
|
+
rubygems_version: 2.0.14
|
180
181
|
signing_key:
|
181
182
|
specification_version: 4
|
182
183
|
summary: VMWare vSphere provider
|