knife-vrealize 1.3.1 → 1.4.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: 07d9ed1c0da967a7f546ea03d5b82b603a80e72f
4
- data.tar.gz: 0d59826e9bd3cbc25639432815870cc2b62f73f5
3
+ metadata.gz: 685f497d4a7f7d514fcbc5ace96b61004f14a6d1
4
+ data.tar.gz: b689e3de61b31e5615f454fd1ebf31c8f42b17be
5
5
  SHA512:
6
- metadata.gz: bf7a696e7bcfe5cdca74c065943d01b35a1fb3a32d5b07f72f01a7603894405057e3d67ff03b81c54c0f932f6e291ed552efd88c97551f3edb38817729304b9c
7
- data.tar.gz: 01bf0b0454049fdab9fd9af2f529e8b3aa32576d0769a3299af3c88c10b88faa208bd79003e25dcdb343b3ac0655d8688948fbfec27b75867bc797223b092839
6
+ metadata.gz: e457deb5adb9e686bfc9ec320ba164d7b0d563d0cfee1b113f20396af2ac5e34ca6b9976fddcf24e6fc14bda22c7f1aeb3cd05641956e5eb1eb7d0345415a36d
7
+ data.tar.gz: 5d4762e856625283df25a725e789467491d13254dd75ddcadc165ac52b996e4ca293dbf86326a65a271c10309e49209227303fc97fcd89b18e508a080ff04bc0
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # knife-vrealize Change Log
2
2
 
3
+ ## Release: v1.4.0
4
+ * [pr#10](https://github.com/chef-partners/knife-vrealize/pull/10) Added logic to prefer the IP address if it's available, but fallback to the rsource record / server name if it's not.
5
+
3
6
  ## Release: v1.3.1
4
7
  * [pr#9](https://github.com/chef-partners/knife-vrealize/pull/9) Bug fix for handling of extra parameters, which were never properly sent to the vRA API
5
8
 
@@ -109,7 +109,7 @@ class Chef
109
109
  super
110
110
 
111
111
  config[:chef_node_name] = locate_config_value(:chef_node_name) ? locate_config_value(:chef_node_name) : server.name
112
- config[:bootstrap_ip_address] = server.ip_addresses.first
112
+ config[:bootstrap_ip_address] = hostname_for_server
113
113
  end
114
114
 
115
115
  def extra_params
@@ -130,6 +130,12 @@ class Chef
130
130
  param[:type] == 'string' || param[:type] == 'integer'
131
131
  end
132
132
  end
133
+
134
+ def hostname_for_server
135
+ ip_address = server.ip_addresses.first
136
+
137
+ ip_address.nil? ? server.name : ip_address
138
+ end
133
139
  end
134
140
  end
135
141
  end
@@ -17,5 +17,5 @@
17
17
  #
18
18
 
19
19
  module KnifeVrealize
20
- VERSION = '1.3.1'
20
+ VERSION = '1.4.0'
21
21
  end
@@ -147,4 +147,24 @@ describe Chef::Knife::Cloud::VraServerCreate do
147
147
  end
148
148
  end
149
149
  end
150
+
151
+ describe '#hostname_for_server' do
152
+ let(:server) { double('server') }
153
+ let(:ip_addresses) { [ '1.2.3.4' ] }
154
+
155
+ it 'returns the IP address if it exists' do
156
+ allow(subject).to receive(:server).and_return(server)
157
+ allow(server).to receive(:ip_addresses).and_return(ip_addresses)
158
+
159
+ expect(subject.hostname_for_server).to eq('1.2.3.4')
160
+ end
161
+
162
+ it 'returns the hostname if the IP address is missing' do
163
+ allow(subject).to receive(:server).and_return(server)
164
+ allow(server).to receive(:ip_addresses).and_return([])
165
+ allow(server).to receive(:name).and_return('test_name')
166
+
167
+ expect(subject.hostname_for_server).to eq('test_name')
168
+ end
169
+ end
150
170
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-vrealize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Partner Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-29 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef