vagrant-dnsdock-hostupdater 0.0.21 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +28 -0
- data/vagrant-dnsdock-hostupdater.gemspec +27 -0
- metadata +3 -22
- data/lib/client.rb +0 -4
- data/lib/event-watcher.rb +0 -51
- data/lib/host-manager.rb +0 -298
- data/lib/hosts/aef/hosts.rb +0 -51
- data/lib/hosts/aef/hosts/comment.rb +0 -73
- data/lib/hosts/aef/hosts/element.rb +0 -108
- data/lib/hosts/aef/hosts/empty_element.rb +0 -50
- data/lib/hosts/aef/hosts/entry.rb +0 -123
- data/lib/hosts/aef/hosts/file.rb +0 -252
- data/lib/hosts/aef/hosts/helpers.rb +0 -121
- data/lib/hosts/aef/hosts/section.rb +0 -141
- data/lib/hosts/aef/hosts/version.rb +0 -29
- data/lib/hosts/aef/linebreak/linebreak.rb +0 -148
- data/lib/hosts/hosts.rb +0 -25
- data/lib/hosts/hosts/bare.rb +0 -23
- data/lib/launch-control +0 -46
- data/lib/server.rb +0 -3
- data/lib/vagrant-dnsdock-hostupdater.rb +0 -10
- data/lib/vagrant-dnsdock-hostupdater/command.rb +0 -12
- data/lib/vagrant-dnsdock-hostupdater/plugin.rb +0 -90
- data/lib/version.rb +0 -5
data/lib/hosts/hosts/bare.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
=begin
|
3
|
-
Copyright Alexander E. Fischer <aef@raxys.net>, 2012
|
4
|
-
|
5
|
-
This file is part of Hosts.
|
6
|
-
|
7
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
8
|
-
purpose with or without fee is hereby granted, provided that the above
|
9
|
-
copyright notice and this permission notice appear in all copies.
|
10
|
-
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
12
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
13
|
-
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
14
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
15
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
16
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
17
|
-
PERFORMANCE OF THIS SOFTWARE.
|
18
|
-
=end
|
19
|
-
|
20
|
-
# Require this file if you don't want an alias for Aef::Hosts named simply
|
21
|
-
# Hosts.
|
22
|
-
|
23
|
-
require_relative '../hosts'
|
data/lib/launch-control
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- mode: ruby -*-
|
3
|
-
# vi: set ft=ruby :
|
4
|
-
require 'docker'
|
5
|
-
require 'yaml'
|
6
|
-
|
7
|
-
|
8
|
-
# build up hash of id => project name
|
9
|
-
id_project_hash = {}
|
10
|
-
Docker::Container.all(all: true, filters: { status: ["running"] }.to_json).each do |container|
|
11
|
-
# puts container.info['id']
|
12
|
-
# puts container.info['Labels']['com.docker.compose.project'].inspect
|
13
|
-
|
14
|
-
id_project_hash[container.info['id']] = container.info['Labels']['com.docker.compose.project']
|
15
|
-
# puts container.info['NetworkSettings']['IPAddress']
|
16
|
-
# puts container.info.to_yaml
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
module HostManager
|
21
|
-
def self.register(hostname, ip)
|
22
|
-
entry = "#{ip} #{hostname}"
|
23
|
-
puts entry
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
Docker::Network.all.each do |network|
|
28
|
-
# puts network.info['Options'].inspect
|
29
|
-
# puts network.inspect
|
30
|
-
network.info['Containers'].each do |pair|
|
31
|
-
id = pair[0]
|
32
|
-
container = pair[1]
|
33
|
-
ip = container['IPv4Address'][/[^\/]+/]
|
34
|
-
if id_project_hash.key?(id) and id_project_hash[id]
|
35
|
-
project_name = id_project_hash[id]
|
36
|
-
HostManager.register("#{container['Name']}.#{project_name}.local", ip)
|
37
|
-
elsif
|
38
|
-
HostManager.register("#{container['Name']}.local", ip)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# Docker::Event.stream { |event|
|
44
|
-
# # respond to all events
|
45
|
-
# puts event.Attributes.name;
|
46
|
-
# }
|
data/lib/server.rb
DELETED
@@ -1,90 +0,0 @@
|
|
1
|
-
module Vagrant
|
2
|
-
module DnsdockHostUpdater
|
3
|
-
|
4
|
-
module OS
|
5
|
-
def OS.windows?
|
6
|
-
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
7
|
-
end
|
8
|
-
|
9
|
-
def OS.mac?
|
10
|
-
(/darwin/ =~ RUBY_PLATFORM) != nil
|
11
|
-
end
|
12
|
-
|
13
|
-
def OS.unix?
|
14
|
-
!OS.windows?
|
15
|
-
end
|
16
|
-
|
17
|
-
def OS.linux?
|
18
|
-
OS.unix? and not OS.mac?
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class Plugin < Vagrant.plugin('2')
|
23
|
-
name "dnsdock-host-updater"
|
24
|
-
|
25
|
-
description <<-DESC
|
26
|
-
Updates hosts for docker containers on guest VM.
|
27
|
-
DESC
|
28
|
-
|
29
|
-
@started = false
|
30
|
-
|
31
|
-
# Add command for `$ vagrant dnsdock-host-updater`
|
32
|
-
# command 'dnsdock-host-updater' do
|
33
|
-
# require_relative 'command'
|
34
|
-
# Command
|
35
|
-
# end
|
36
|
-
|
37
|
-
def self.pid_path
|
38
|
-
File.expand_path('~/.docker-host-manager.pid')
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.log(msg)
|
42
|
-
puts "[vagrant-dnsdock-hostupdater] #{msg}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.pid
|
46
|
-
File.exist?(pid_path) ? File.read(pid_path) : nil
|
47
|
-
end
|
48
|
-
|
49
|
-
def self.close_manager
|
50
|
-
if pid
|
51
|
-
log "Already running with PID: #{pid}"
|
52
|
-
begin
|
53
|
-
log "Attempting to stop server with PID: #{pid}"
|
54
|
-
Process.kill('KILL', pid.to_i)
|
55
|
-
rescue
|
56
|
-
log "Unable to kill process with ID: #{pid}. This may be because the process has already been terminated."
|
57
|
-
end
|
58
|
-
|
59
|
-
log "Cleaning up PID file: #{pid_path}"
|
60
|
-
File.delete(pid_path)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.init_plugin
|
65
|
-
server_path = File.expand_path('../../server.rb', __FILE__)
|
66
|
-
|
67
|
-
if @started
|
68
|
-
return
|
69
|
-
end
|
70
|
-
|
71
|
-
close_manager
|
72
|
-
|
73
|
-
pid = Process.spawn("ruby #{server_path}")
|
74
|
-
log "Started server with PID: #{pid}"
|
75
|
-
|
76
|
-
if pid
|
77
|
-
pid_file = File.open(pid_path, 'w')
|
78
|
-
pid_file << pid
|
79
|
-
pid_file.close
|
80
|
-
log "Wrote server PID (#{pid}) to #{pid_path}"
|
81
|
-
Process.detach(pid)
|
82
|
-
@started = true
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
action_hook(:up, :machine_action_up) { init_plugin }
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|