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.
@@ -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,3 +0,0 @@
1
- require_relative 'host-manager'
2
-
3
- HostManager::Server.create('0.0.0.0', 2991)
@@ -1,10 +0,0 @@
1
- require 'bundler'
2
-
3
- begin
4
- require 'vagrant'
5
- rescue LoadError
6
- Bundler.require(:default, :development)
7
- end
8
-
9
- require 'vagrant-dnsdock-hostupdater/plugin'
10
- require 'vagrant-dnsdock-hostupdater/command'
@@ -1,12 +0,0 @@
1
- module Vagrant
2
- module DnsdockHostUpdater
3
- class Command < Vagrant.plugin('2', :command)
4
- def execute
5
- puts 'command firing...'
6
- exec('echo "Command fired!"')
7
- 0
8
- end
9
- end
10
- end
11
-
12
- end
@@ -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
data/lib/version.rb DELETED
@@ -1,5 +0,0 @@
1
- module Vagrant
2
- module DnsdockHostUpdater
3
- VERSION = '0.0.21'.freeze
4
- end
5
- end