vagrant-vsphere 0.9.2 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35db4ce11715c001c9a4bebf6c8aff7217b49693
4
- data.tar.gz: 7f5cd308f0ccc72b11909bf7bb08a1d9f4216c90
3
+ metadata.gz: 6b756fdb157919fecd29925a00eff198363f03cb
4
+ data.tar.gz: 469e8fb045b8480ea7421383b89de2bb64051eee
5
5
  SHA512:
6
- metadata.gz: 13ce317e8bbeb73c86e4f63201dc9b2c7290bb8f6f431b0e0f6f9dcbd903a859a41fb877de5aae001c60b717ef7abadd42018d26a89fd79874f3ac8ef5166367
7
- data.tar.gz: b882e45a9e16398cb60d5df25fdc2b134fb8b8b0ca7ba02227ac617ada0064a259d6143c79cd11de8b142c23b7c4375bea4a027b1b819eaaaabee4bf2a0ab4ae
6
+ metadata.gz: 10a8751efe9d1c22a6cd82aa8d77d66d6fdb2d52bba06998f37ea0c38baf6572b54ab3b4a8bb4a489a46766bedefffed896d80a3f4dcda2d77405cb52b35b6be
7
+ data.tar.gz: 79ca29a2965f8cdbd1babbda23129819429c50624cf863385df6465fedc7a21903f90d50b494b01943fd52e7cee8e6f797443842a4647e73f481d8939dcfabe9
data/README.md CHANGED
@@ -12,9 +12,9 @@ This provider is built on top of the [RbVmomi](https://github.com/vmware/rbvmomi
12
12
  * libxml2, libxml2-dev, libxslt, libxslt-dev
13
13
 
14
14
  ## Current Version
15
- **0.9.2**
15
+ **0.10.0**
16
16
 
17
- vagrant-vsphere (0.9.2) is available from [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
17
+ vagrant-vsphere (0.10.0) is available from [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
18
18
 
19
19
  ## Installation
20
20
 
@@ -93,6 +93,7 @@ This provider has the following settings, all are required unless noted:
93
93
  * `resource_pool_name` - the resource pool for the new VM. If not supplied, and cloning from a template, uses the root resource pool
94
94
  * `clone_from_vm` - _Optional_ use a virtual machine instead of a template as the source for the cloning operation
95
95
  * `template_name` - the VM or VM template to clone
96
+ * `vm_base_path` - _Optional_ path to folder where new VM sould be created, if not specified template's parent folder will be used
96
97
  * `name` - _Optional_ name of the new VM, if missing the name will be auto generated
97
98
  * `customization_spec_name` - _Optional_ customization spec for the new VM
98
99
  * `data_store_name` - _Optional_ the datastore where the VM will be located
@@ -172,7 +173,9 @@ This is useful if running Vagrant from multiple directories or if multiple machi
172
173
  * reuse folder sync code from Vagrant core. [#66 mkuzmin:sync-folders](https://github.com/nsidc/vagrant-vsphere/pull/66)
173
174
  * 0.9.2
174
175
  * Instruct vagrant to set the guest hostname according to Vagrantfile [#69 ddub:set-hostname](https://github.com/nsidc/vagrant-vsphere/pull/69)
175
-
176
+ * 0.10.0
177
+ * new optional parameter to clone into custom folder in vSphere [#73 mikola-spb:vm-base-path](https://github.com/nsidc/vagrant-vsphere/pull/73)
178
+ * follows semvar better, this adds functionality in a backwards compatible way, so bumps the minor. 0.9.0, should have been a major version.
176
179
 
177
180
  ## Versioning
178
181
 
@@ -21,8 +21,9 @@ module VagrantPlugins
21
21
  name = get_name machine, config
22
22
  dc = get_datacenter connection, machine
23
23
  template = dc.find_vm config.template_name
24
-
25
24
  raise Errors::VSphereError, :'missing_template' if template.nil?
25
+ vm_base_folder = get_vm_base_folder dc, template, config
26
+ raise Errors::VSphereError, :'invalid_base_path' if vm_base_folder.nil?
26
27
 
27
28
  begin
28
29
  location = get_location connection, machine, config, template
@@ -32,10 +33,10 @@ module VagrantPlugins
32
33
  spec[:customization] = get_customization_spec(machine, customization_info) unless customization_info.nil?
33
34
 
34
35
  env[:ui].info I18n.t('vsphere.creating_cloned_vm')
35
- env[:ui].info " -- #{config.clone_from_vm ? "Source" : "Template"} VM: #{config.template_name}"
36
- env[:ui].info " -- Name: #{name}"
36
+ env[:ui].info " -- #{config.clone_from_vm ? "Source" : "Template"} VM: #{template.pretty_path}"
37
+ env[:ui].info " -- Target VM: #{vm_base_folder.pretty_path}/#{name}"
37
38
 
38
- new_vm = template.CloneVM_Task(:folder => template.parent, :name => name, :spec => spec).wait_for_completion
39
+ new_vm = template.CloneVM_Task(:folder => vm_base_folder, :name => name, :spec => spec).wait_for_completion
39
40
  rescue Errors::VSphereError => e
40
41
  raise
41
42
  rescue Exception => e
@@ -125,6 +126,14 @@ module VagrantPlugins
125
126
  # milliseconds + random number suffix to allow for simultaneous `vagrant up` of the same box in different dirs
126
127
  prefix + "_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
127
128
  end
129
+
130
+ def get_vm_base_folder(dc, template, config)
131
+ if config.vm_base_path.nil?
132
+ template.parent
133
+ else
134
+ dc.vmFolder.traverse(config.vm_base_path, RbVmomi::VIM::Folder)
135
+ end
136
+ end
128
137
  end
129
138
  end
130
139
  end
@@ -13,6 +13,7 @@ module VagrantPlugins
13
13
  attr_accessor :clone_from_vm
14
14
  attr_accessor :template_name
15
15
  attr_accessor :name
16
+ attr_accessor :vm_base_path
16
17
  attr_accessor :customization_spec_name
17
18
  attr_accessor :data_store_name
18
19
  attr_accessor :linked_clone
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VSphere
3
- VERSION = '0.9.2'
3
+ VERSION = '0.10.0'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -24,6 +24,8 @@ en:
24
24
  errors:
25
25
  missing_template: |-
26
26
  Configured template/source VM could not be found
27
+ invalid_base_path: |-
28
+ Could not find base path for target VM, check 'vm_base_path' configuration value
27
29
  missing_datacenter: |-
28
30
  Configured data center not found
29
31
  missing_compute_resource: |-
data/spec/clone_spec.rb CHANGED
@@ -1,11 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
+ CUSTOM_VM_FOLDER = 'custom_vm_folder'
4
+
3
5
  describe VagrantPlugins::VSphere::Action::Clone do
4
6
  before :each do
5
7
  @env[:vSphere_connection] = @vim
6
8
  end
7
9
 
8
- it 'should create a CloneVM task' do
10
+ it "should create a CloneVM task with template's parent" do
9
11
  call
10
12
  expect(@template).to have_received(:CloneVM_Task).with({
11
13
  :folder => @data_center,
@@ -14,6 +16,19 @@ describe VagrantPlugins::VSphere::Action::Clone do
14
16
  })
15
17
  end
16
18
 
19
+ it 'should create a CloneVM task with custom folder when given vm base path' do
20
+ custom_base_folder = double(CUSTOM_VM_FOLDER,
21
+ :pretty_path => "#{@data_center.pretty_path}/#{CUSTOM_VM_FOLDER}")
22
+ @machine.provider_config.stub(:vm_base_path).and_return(CUSTOM_VM_FOLDER)
23
+ @data_center.vmFolder.stub(:traverse).with(CUSTOM_VM_FOLDER, RbVmomi::VIM::Folder).and_return(custom_base_folder)
24
+ call
25
+ expect(@template).to have_received(:CloneVM_Task).with({
26
+ :folder => custom_base_folder,
27
+ :name => NAME,
28
+ :spec => {:location => {:pool => @child_resource_pool} }
29
+ })
30
+ end
31
+
17
32
  it 'should set the machine id to be the new UUID' do
18
33
  call
19
34
  expect(@machine).to have_received(:id=).with(NEW_UUID)
data/spec/spec_helper.rb CHANGED
@@ -42,6 +42,7 @@ RSpec.configure do |config|
42
42
  :data_center_name => nil,
43
43
  :compute_resource_name => 'testcomputeresource',
44
44
  :resource_pool_name => 'testresourcepool',
45
+ :vm_base_path => nil,
45
46
  :template_name => TEMPLATE,
46
47
  :name => NAME,
47
48
  :insecure => true,
@@ -96,12 +97,14 @@ RSpec.configure do |config|
96
97
 
97
98
  @data_center = double('data_center',
98
99
  :vmFolder => vm_folder,
100
+ :pretty_path => "data_center/#{vm_folder}",
99
101
  :find_compute_resource => double('compute resource', :resourcePool => @root_resource_pool))
100
102
 
101
103
  @template = double('template_vm',
102
104
  :parent => @data_center,
105
+ :pretty_path => "#{@data_center.pretty_path}/template_vm",
103
106
  :CloneVM_Task => double('result',
104
- :wait_for_completion => double('new_vm', :config => double('config', :uuid => NEW_UUID))))
107
+ :wait_for_completion => double('new_vm', :config => double('config', :uuid => NEW_UUID))))
105
108
 
106
109
  @data_center.stub(:find_vm).with(TEMPLATE).and_return(@template)
107
110
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Grauch