vagrant-dnsdock-hostupdater 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/host-manager.rb +31 -16
  3. data/lib/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0735d302cf7d32e2bf91f1f871ccd2aced168070
4
- data.tar.gz: 05f38df631b296bee7e20c29dcd352fcee8bd624
3
+ metadata.gz: aa90639855cf134d5b9dbd02ab45a53fae9d6952
4
+ data.tar.gz: 0267f2fee7cc93cce385a256bab7e4153f53f1ea
5
5
  SHA512:
6
- metadata.gz: ecc2567cac7f275dd518eadf3e1091653906803a1652e5fdf68dab7254e3343c93cf9bfda007d7977a16ad69603afea693d3f9a828f7e10a62475dbaa2e4aba1
7
- data.tar.gz: 3a73cf981db75accfb390b198df2b2702cfe8883dc67e55b7eeb63f59ca0c892b122a302d2210ae0d3ae0e68769a1c6e174e8625dbba9a8d76d14e6239a9a269
6
+ metadata.gz: 4d30d0032da17b0ec47b3eaa38c27718d6683b078b5f3245482830e0994c829f7aac3a4648ddfc0a35e7672a4f0f73d9a1084558c64884c2c2e94793c0fdb890
7
+ data.tar.gz: 7bba31f86f5f0e0ca5e5da72cedcc0fdad07c26bd0161213f2adde3ca553c8d43af844651107903aff97d3c7bd92f70ecd4ec233485d47d0aba317eb89c35d8c
data/lib/host-manager.rb CHANGED
@@ -90,7 +90,7 @@ module HostManager
90
90
  end
91
91
  end
92
92
  execute(data['action'], data['hostname'], data['ip'], data['containerId'])
93
-
93
+
94
94
  elsif data.is_a?(Array)
95
95
  hosts = get_hosts
96
96
 
@@ -104,13 +104,18 @@ module HostManager
104
104
 
105
105
  # add recieved entries
106
106
  data.each do |entry|
107
- execute('create', entry['hostname'], entry['ip'], entry['containerId'])
107
+ comment = HostManager.comment_prefix + (entry['containerId'] ? " Container ID: #{entry['containerId']}" : '')
108
+
109
+ hosts.elements << Hosts::Entry.new(entry['ip'], entry['hostname'], :comment => comment)
110
+ hosts.write
108
111
  end
109
112
 
113
+ hosts.write
114
+
110
115
  end
111
-
116
+
112
117
  end
113
-
118
+
114
119
  rescue => e
115
120
  log.error("Caught exception attempting to execute with data #{content}. #{e}")
116
121
  end
@@ -207,21 +212,31 @@ module HostManager
207
212
 
208
213
  def sync_hosts(container_data)
209
214
  data = []
210
- container_data.each do |container|
211
- container.info['Names'].each do |name|
212
- ip = container.info['NetworkSettings']['IPAddress']
213
-
214
- if ip
215
- item = {
216
- :hostname => host_name(name),
217
- :ip => ip,
218
- :containerId => container.info['id']
219
- }
220
-
221
- data.push(item)
215
+
216
+ if container_data && container_data.is_a?(Array)
217
+ container_data.each do |container_info|
218
+ container = Docker::Container.get(container_info.info['id'])
219
+
220
+ if container.info['State']['Running']
221
+ name = container.info['Name']
222
+ if name
223
+ ip = container.info['NetworkSettings']['IPAddress']
224
+
225
+ if ip
226
+ item = {
227
+ :hostname => host_name(name),
228
+ :ip => ip,
229
+ :containerId => container.info['id']
230
+ }
231
+
232
+ data.push(item)
233
+ end
234
+ end
222
235
  end
236
+
223
237
  end
224
238
 
239
+ send(data)
225
240
  end
226
241
  end
227
242
 
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module DnsdockHostUpdater
3
- VERSION = '0.0.12'.freeze
3
+ VERSION = '0.0.13'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-dnsdock-hostupdater
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Coit