chef-metal-lxc 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef_metal_lxc/lxc_transport.rb +30 -21
- data/lib/chef_metal_lxc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ad611e66ac9a796b8a0c125031d1cf32848a5ed
|
4
|
+
data.tar.gz: 0cfc4b4906340f4d689d1ec647fa8882429a4eb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 475be1de802665c6f8c963ff2694acd434fdbbe24709fa9f24cc2477a74aee4a50c1041eecca5e67f1fc13f8bcd7b508d9a4927f92cc0347234a7a6ecbc435f2
|
7
|
+
data.tar.gz: d6fdd96c32aed28b57c37a74c107aa773b9718dace9c875f6729af72bddce4bf635acddb3eee1c6196ee0ab427ab488e0890c37ebe7d8809ba4be864c5fd0536
|
@@ -4,6 +4,8 @@ require 'chef/mixin/shell_out'
|
|
4
4
|
require 'lxc/extra/proxy_client_side'
|
5
5
|
require 'lxc/extra/proxy_server_side'
|
6
6
|
require 'lxc/extra/channel'
|
7
|
+
require 'uri'
|
8
|
+
require 'socket'
|
7
9
|
|
8
10
|
module ChefMetalLXC
|
9
11
|
class LXCTransport < ChefMetal::Transport
|
@@ -51,32 +53,39 @@ module ChefMetalLXC
|
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
|
-
def
|
55
|
-
|
56
|
-
|
57
|
-
|
56
|
+
def make_url_available_to_remote(local_url)
|
57
|
+
uri = URI(local_url)
|
58
|
+
host = Socket.getaddrinfo(uri.host, uri.scheme, nil, :STREAM)[0][3]
|
59
|
+
if host == '127.0.0.1' || host == '[::1]'
|
60
|
+
|
61
|
+
Chef::Log.debug("Forwarding container port #{uri.port} to local port #{uri.port}")
|
62
|
+
# Create the channel that will let the container and the host talk to each other
|
63
|
+
channel = LXC::Extra::Channel.new
|
64
|
+
|
65
|
+
# Start the container side of the proxy, listening for client connections
|
66
|
+
pid = container.attach do
|
67
|
+
begin
|
68
|
+
server = TCPServer.new('127.0.0.1', uri.port)
|
69
|
+
proxy = LXC::Extra::ProxyClientSide.new(channel, server)
|
70
|
+
proxy.start
|
71
|
+
rescue
|
72
|
+
Chef::Log.error("ERROR in proxy (container side): #{$!}\n#{$!.backtrace.join("\n")}")
|
73
|
+
raise
|
74
|
+
end
|
75
|
+
end
|
58
76
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
77
|
+
# Start the host side of the proxy, which contacts the real server
|
78
|
+
thread = Thread.new do
|
79
|
+
proxy = LXC::Extra::ProxyServerSide.new(channel) do
|
80
|
+
TCPSocket.new('127.0.0.1', uri.port)
|
81
|
+
end
|
64
82
|
proxy.start
|
65
|
-
rescue
|
66
|
-
Chef::Log.error("ERROR in proxy (container side): #{$!}\n#{$!.backtrace.join("\n")}")
|
67
|
-
raise
|
68
83
|
end
|
69
|
-
end
|
70
84
|
|
71
|
-
|
72
|
-
thread = Thread.new do
|
73
|
-
proxy = LXC::Extra::ProxyServerSide.new(channel) do
|
74
|
-
TCPSocket.new('127.0.0.1', local_port)
|
75
|
-
end
|
76
|
-
proxy.start
|
77
|
-
end
|
85
|
+
@port_forwards << [ pid, thread, channel ]
|
78
86
|
|
79
|
-
|
87
|
+
end
|
88
|
+
local_url
|
80
89
|
end
|
81
90
|
|
82
91
|
def read_file(path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-metal-lxc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ranjib Dey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chef
|