vagrant-vsphere 0.13.1 → 0.14.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: d4dce496c79c53cffa0fa7364379c8331e4b918f
4
- data.tar.gz: edc297f71f5fef2c79e03f2c6d5c25c8d4c67c90
3
+ metadata.gz: 18ea9f258ae0478f7b099bd5f90ab8cee9e5de79
4
+ data.tar.gz: 39813243c2ded6a1e451f504533cea4b4c230745
5
5
  SHA512:
6
- metadata.gz: ebf9859f8b9c82f8b0807e549a2d5a267fc8966b5c450837eab8c4cef99e47348e13f7baa22643c6f2ad5eca145c677bf260674ebd72e7143fe69995912dfedf
7
- data.tar.gz: 5ee5e449d626a37a7075d1581ba13ee12022f6e16f1385ff7bb2ff8a003c0217bada43864ab780ad9bde7f03fa8199b4d50f68251dc1a9381667a821a52bd1f8
6
+ metadata.gz: 6be072277703883e5e6876dc16c456656ca90073ea5c4d7b0fdb7ba8fab42792075abf3c598c0f6c69f273b9d349703ad08a18104af227c894eda3a8ccb68b40
7
+ data.tar.gz: 2281f71c3ad514d185aecda5962291ae1114019ad0b37d0089f4cfb186fea556d9df8a80169b8f8a57359582c0c2787295952f1805f883271bb8319c9980dbcd
data/.bumpversion.cfg CHANGED
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.13.1
2
+ current_version = 0.14.0
3
3
  tag = true
4
4
  commit = true
5
5
 
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
- **version: 0.13.1**
15
+ **version: 0.14.0**
16
16
 
17
- vagrant-vsphere (**version: 0.13.1**) is available from [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
17
+ vagrant-vsphere (**version: 0.14.0**) is available from [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
18
18
 
19
19
  ## Installation
20
20
 
@@ -184,7 +184,9 @@ This is useful if running Vagrant from multiple directories or if multiple machi
184
184
  * Find and install box file for multi-provider boxes automatically [#86 mkuzmin:install-box](https://github.com/nsidc/vagrant-vsphere/pull/86) & [#87 mkuzmin/provider-name](https://github.com/nsidc/vagrant-vsphere/pull/87).
185
185
  * 0.13.1
186
186
  * Change Nokogiri Major Version dependency [#90 highsineburgh:SAITRADLab-master](https://github.com/nsidc/vagrant-vsphere/pull/90)
187
-
187
+ * 0.14.0 Add vlan configuration [#91 rylarson:add-vlan-configuration](https://github.com/nsidc/vagrant-vsphere/pull/91)
188
+ * Added a new configuration option 'vlan' that lets you specify the vlan string
189
+ * If vlan is set, the clone spec is modified with an edit action to connect the first NIC on the VM to the configured VLAN.
188
190
 
189
191
 
190
192
  ## Versioning
@@ -31,6 +31,7 @@ module VagrantPlugins
31
31
  customization_info = get_customization_spec_info_by_name connection, machine
32
32
 
33
33
  spec[:customization] = get_customization_spec(machine, customization_info) unless customization_info.nil?
34
+ add_custom_vlan(template, dc, spec, config.vlan) unless config.vlan.nil?
34
35
 
35
36
  env[:ui].info I18n.t('vsphere.creating_cloned_vm')
36
37
  env[:ui].info " -- #{config.clone_from_vm ? "Source" : "Template"} VM: #{template.pretty_path}"
@@ -131,9 +132,25 @@ module VagrantPlugins
131
132
  if config.vm_base_path.nil?
132
133
  template.parent
133
134
  else
134
- dc.vmFolder.traverse(config.vm_base_path, RbVmomi::VIM::Folder, create=true)
135
+ dc.vmFolder.traverse(config.vm_base_path, RbVmomi::VIM::Folder, create = true)
135
136
  end
136
137
  end
138
+
139
+ def add_custom_vlan(template, dc, spec, vlan)
140
+ spec[:config] = RbVmomi::VIM.VirtualMachineConfigSpec(:deviceChange => Array.new)
141
+ network = get_network_by_name(dc, vlan)
142
+ config = template.config
143
+ card = config.hardware.device.grep(RbVmomi::VIM::VirtualEthernetCard).first or fail Errors::VSphereError, :missing_network_card
144
+ begin
145
+ switch_port = RbVmomi::VIM.DistributedVirtualSwitchPortConnection(:switchUuid => network.config.distributedVirtualSwitch.uuid, :portgroupKey => network.key)
146
+ card.backing.port = switch_port
147
+ rescue
148
+ # not connected to a distibuted switch?
149
+ card.backing.deviceName = network.name
150
+ end
151
+ dev_spec = RbVmomi::VIM.VirtualDeviceConfigSpec(:device => card, :operation => "edit")
152
+ spec[:config][:deviceChange].push dev_spec
153
+ end
137
154
  end
138
155
  end
139
156
  end
@@ -19,6 +19,7 @@ module VagrantPlugins
19
19
  attr_accessor :linked_clone
20
20
  attr_accessor :proxy_host
21
21
  attr_accessor :proxy_port
22
+ attr_accessor :vlan
22
23
 
23
24
  def validate(machine)
24
25
  errors = _detected_errors
@@ -35,6 +35,10 @@ module VagrantPlugins
35
35
 
36
36
  get_datacenter(connection, machine).find_datastore name or fail Errors::VSphereError, :missing_datastore
37
37
  end
38
+
39
+ def get_network_by_name(dc, name)
40
+ dc.network.find { |f| f.name == name } or fail Errors::VSphereError, :missing_vlan
41
+ end
38
42
  end
39
43
  end
40
44
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VSphere
3
- VERSION = '0.13.1'
3
+ VERSION = '0.14.0'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -40,6 +40,10 @@ en:
40
40
  Configured data store not found
41
41
  too_many_private_networks: |-
42
42
  There a more private networks configured than can be assigned to the customization spec
43
+ missing_vlan: |-
44
+ Configured vlan not found
45
+ missing_network_card: |-
46
+ Cannot find network card to customize
43
47
  config:
44
48
  host: |-
45
49
  Configuration must specify a vSphere host
data/spec/clone_spec.rb CHANGED
@@ -39,6 +39,27 @@ describe VagrantPlugins::VSphere::Action::Clone do
39
39
  expect(@app).to have_received :call
40
40
  end
41
41
 
42
+ it 'should create a CloneVM spec with configured vlan' do
43
+ @machine.provider_config.stub(:vlan).and_return('vlan')
44
+ network = double('network', :name => 'vlan')
45
+ network.stub(:config).and_raise(StandardError)
46
+ @data_center.stub(:network).and_return([network])
47
+ call
48
+
49
+ expected_config = RbVmomi::VIM.VirtualMachineConfigSpec(:deviceChange => Array.new)
50
+ expected_dev_spec = RbVmomi::VIM.VirtualDeviceConfigSpec(:device => @device, :operation => "edit")
51
+ expected_config[:deviceChange].push expected_dev_spec
52
+
53
+ expect(@template).to have_received(:CloneVM_Task).with({
54
+ :folder => @data_center,
55
+ :name => NAME,
56
+ :spec => {:location =>
57
+ {:pool => @child_resource_pool},
58
+ :config => expected_config
59
+ }
60
+ })
61
+ end
62
+
42
63
  it 'should set static IP when given config spec' do
43
64
  @machine.provider_config.stub(:customization_spec_name).and_return('spec')
44
65
  call
data/spec/spec_helper.rb CHANGED
@@ -52,7 +52,8 @@ RSpec.configure do |config|
52
52
  :clone_from_vm => nil,
53
53
  :linked_clone => nil,
54
54
  :proxy_host => nil,
55
- :proxy_port => nil)
55
+ :proxy_port => nil,
56
+ :vlan => nil)
56
57
  vm_config = double(
57
58
  :vm => double('config_vm',
58
59
  :box => nil,
@@ -101,11 +102,20 @@ RSpec.configure do |config|
101
102
  :pretty_path => "data_center/#{vm_folder}",
102
103
  :find_compute_resource => double('compute resource', :resourcePool => @root_resource_pool))
103
104
 
105
+ @device = RbVmomi::VIM::VirtualEthernetCard.new
106
+ @device.stub(:backing).and_return(RbVmomi::VIM::VirtualEthernetCardNetworkBackingInfo.new)
107
+
108
+ @virtual_hardware = double('virtual_hardware',
109
+ :device => [@device])
110
+ @template_config = double('template_config',
111
+ :hardware => @virtual_hardware)
112
+
104
113
  @template = double('template_vm',
105
114
  :parent => @data_center,
106
115
  :pretty_path => "#{@data_center.pretty_path}/template_vm",
107
116
  :CloneVM_Task => double('result',
108
- :wait_for_completion => double('new_vm', :config => double('config', :uuid => NEW_UUID))))
117
+ :wait_for_completion => double('new_vm', :config => double('config', :uuid => NEW_UUID))),
118
+ :config => @template_config)
109
119
 
110
120
  @data_center.stub(:find_vm).with(TEMPLATE).and_return(@template)
111
121
 
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.13.1
4
+ version: 0.14.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-09-18 00:00:00.000000000 Z
11
+ date: 2014-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  version: '0'
175
175
  requirements: []
176
176
  rubyforge_project:
177
- rubygems_version: 2.2.2
177
+ rubygems_version: 2.0.14
178
178
  signing_key:
179
179
  specification_version: 4
180
180
  summary: VMWare vSphere provider