vagrant-vsphere 1.8.1 → 1.9.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: 44eaadb2635893728366e8b5feb84895f30ebb9f
4
- data.tar.gz: d543a5d6bd671ffe7ee51502d23df6c79e07285c
3
+ metadata.gz: b214391a7269ce42e0026ec47e2f9a9964fa8d97
4
+ data.tar.gz: 3aea2543fc0e5b23e503991469d20319ef1f3b56
5
5
  SHA512:
6
- metadata.gz: 1de3807f0c71b4572e15f45fc95480de464eeb6838f4b565a97c4ec9209e2dd21ef918b4783753c06fe77e1bd1eb9f0a351eaf21da7c8978a644df2300f29006
7
- data.tar.gz: 94ec4d567b84a2ab4cd7df12c06f3fbd7d470dac1c3f218b15e1063c013dac79344f5f954f00b9f4f6a8fa0385d5d187fc0109ebf5bf9776c1a57d468ec19bf4
6
+ metadata.gz: 2f36e7102acea74674c86bf8fb892c52fe24f636ef049708d038c023760271b975fd3cc90557225fcee02d648bb199099903372f5c927a14a3975e1071bbbc4e
7
+ data.tar.gz: f255d642094aa816e751474da9bbdb9ca855dcaebcc131f1fe941110d379bf3953d024d30c3c598120214718b4516423009a227fe1dd57ea839a844c862c40b6
data/.bumpversion.cfg CHANGED
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 1.8.1
2
+ current_version = 1.9.0
3
3
  tag = true
4
4
  commit = true
5
5
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## [1.9.0 (2016-05-17)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.9.0)
2
+
3
+ - Add real_nic_ip option/logic to support VMs with multiple bridge adapters
4
+ ([vagrant-vsphere:invalid_ip_address_fix](https://github.com/nsidc/vagrant-vsphere/pull/193)).
5
+
1
6
  ## [1.8.1 (2016-04-27)](https://github.com/nsidc/vagrant-vsphere/releases/tag/v1.8.1)
2
7
 
3
8
  - Fix error for initial VLAN/virtual switch support
data/README.md CHANGED
@@ -19,9 +19,9 @@ This provider is built on top of the
19
19
  * libxml2, libxml2-dev, libxslt, libxslt-dev
20
20
 
21
21
  ## Current Version
22
- **version: 1.8.1**
22
+ **version: 1.9.0**
23
23
 
24
- vagrant-vsphere (**version: 1.8.1**) is available from
24
+ vagrant-vsphere (**version: 1.9.0**) is available from
25
25
  [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
26
26
 
27
27
  ## Installation
@@ -145,6 +145,10 @@ This provider has the following settings, all are required unless noted:
145
145
  where the key must start with `guestinfo.`. VMs with VWware Tools installed can
146
146
  retrieve the value of these variables using the `vmtoolsd` command: `vmtoolsd --cmd 'info-get guestinfo.some.variable'`.
147
147
  * `notes` - _Optional_ Add arbitrary notes to the VM
148
+ * `real_nic_ip` - _Optional_ true/false - Enable logic that forces the acquisition of the ssh IP address
149
+ for a target VM to be retrieved from the list of vm adapters on the host and filtered for a single legitimate
150
+ adapter with a defined interface. An error will be raised if this filter is enabled and multiple valid
151
+ adapters exist on a host.
148
152
 
149
153
  ### Cloning from a VM rather than a template
150
154
 
@@ -13,21 +13,27 @@ module VagrantPlugins
13
13
 
14
14
  def call(env)
15
15
  env[:machine_ssh_info] = get_ssh_info(env[:vSphere_connection], env[:machine])
16
-
17
16
  @app.call env
18
17
  end
19
18
 
20
19
  private
21
20
 
21
+ def filter_guest_nic(vm, machine)
22
+ return vm.guest.ipAddress unless machine.provider_config.real_nic_ip
23
+ ip_addresses = vm.guest.net.select { |g| g.deviceConfigId > 0 }.map { |g| g.ipAddress[0] }
24
+ fail Errors::VSphereError.new, :'multiple_interface_with_real_nic_ip_set' if ip_addresses.size > 1
25
+ ip_addresses.first
26
+ end
27
+
22
28
  def get_ssh_info(connection, machine)
23
29
  return nil if machine.id.nil?
24
30
 
25
31
  vm = get_vm_by_uuid connection, machine
26
-
27
32
  return nil if vm.nil?
28
- return nil if vm.guest.ipAddress.nil? || vm.guest.ipAddress.empty?
33
+ ip_address = filter_guest_nic(vm, machine)
34
+ return nil if ip_address.nil? || ip_address.empty?
29
35
  {
30
- host: vm.guest.ipAddress,
36
+ host: ip_address,
31
37
  port: 22
32
38
  }
33
39
  end
@@ -27,6 +27,7 @@ module VagrantPlugins
27
27
  attr_accessor :cpu_reservation
28
28
  attr_accessor :mem_reservation
29
29
  attr_accessor :extra_config
30
+ attr_accessor :real_nic_ip
30
31
  attr_accessor :notes
31
32
 
32
33
  attr_reader :custom_attributes
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module VSphere
3
- VERSION = '1.8.1'
3
+ VERSION = '1.9.0'
4
4
  end
5
5
  end
data/locales/en.yml CHANGED
@@ -46,6 +46,8 @@ en:
46
46
  Cannot find network card to customize
47
47
  invalid_configuration_linked_clone_with_sdrs: |-
48
48
  Cannot use Linked Clone with Storage DRS
49
+ multiple_interface_with_real_nic_ip_set: |-
50
+ real_nic_ip filtering set with multiple valid VM interfaces available
49
51
 
50
52
  config:
51
53
  host: |-
@@ -23,9 +23,64 @@ describe VagrantPlugins::VSphere::Action::GetSshInfo do
23
23
 
24
24
  it 'should set the ssh info host to the IP an existing VM' do
25
25
  @env[:machine].stub(:id).and_return(EXISTING_UUID)
26
-
27
26
  call
28
27
 
29
28
  expect(@env[:machine_ssh_info][:host]).to be IP_ADDRESS
30
29
  end
30
+
31
+ context 'when acting on a VM with multiple network adapters' do
32
+ before do
33
+ allow(@vm.guest).to receive(:ipAddress) { '127.0.0.2' }
34
+ allow(@vm.guest).to receive(:net) {
35
+ [
36
+ double('guest_nic_info',
37
+ ipAddress: ['127.0.0.2', 'mac address'],
38
+ deviceConfigId: -1
39
+ ),
40
+ double('guest_nic_info',
41
+ ipAddress: ['127.0.0.1', 'mac address'],
42
+ deviceConfigId: 4000
43
+ )
44
+ ]
45
+ }
46
+ @env[:machine].stub(:id).and_return(EXISTING_UUID)
47
+ end
48
+ context 'when the real_nic_ip option is false' do
49
+ it 'sets the ssh info the original adapter' do
50
+ call
51
+ expect(@env[:machine_ssh_info][:host]).to eq '127.0.0.2'
52
+ end
53
+ end
54
+
55
+ context 'when the real_nic_ip option is true' do
56
+ before do
57
+ @env[:machine].provider_config.stub(:real_nic_ip).and_return(true)
58
+ end
59
+ context 'when there are mutiple valid adapters' do
60
+ before do
61
+ allow(@vm.guest).to receive(:net) {
62
+ [
63
+ double('guest_nic_info',
64
+ ipAddress: ['127.0.0.2', 'mac address'],
65
+ deviceConfigId: 4001
66
+ ),
67
+ double('guest_nic_info',
68
+ ipAddress: ['127.0.0.1', 'mac address'],
69
+ deviceConfigId: 4000
70
+ )
71
+ ]
72
+ }
73
+ end
74
+ it 'should raise an error' do
75
+ expect { call }.to raise_error(VagrantPlugins::VSphere::Errors::VSphereError)
76
+ end
77
+ end
78
+
79
+ it 'sets the ssh info host to the correct adapter' do
80
+ call
81
+ expect(@env[:machine_ssh_info][:host]).to eq IP_ADDRESS
82
+ end
83
+
84
+ end
85
+ end
31
86
  end
data/spec/spec_helper.rb CHANGED
@@ -64,7 +64,8 @@ RSpec.configure do |config|
64
64
  mem_reservation: nil,
65
65
  custom_attributes: {},
66
66
  notes: nil,
67
- extra_config: {})
67
+ extra_config: {},
68
+ real_nic_ip: false)
68
69
  vm_config = double(
69
70
  vm: double('config_vm',
70
71
  box: nil,
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: 1.8.1
4
+ version: 1.9.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: 2016-04-27 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri