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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ed7dfed2acc5f5c14b12786111cf062074f2165
4
- data.tar.gz: c34889c04ef95bea3ae6b036a24a39bcd270b654
3
+ metadata.gz: 6ad611e66ac9a796b8a0c125031d1cf32848a5ed
4
+ data.tar.gz: 0cfc4b4906340f4d689d1ec647fa8882429a4eb9
5
5
  SHA512:
6
- metadata.gz: a93dab3facce1903bb30177604f07140881749e28f24668cc3e8f28de1c73f3a2b893b36ec7a3539a0de83c2286efa6247843bbdda0a29bad4476c72f2e4aa19
7
- data.tar.gz: e717b1b724124d7e1d0c9e34cdb63b1b7bee0ebc7e9c2145395020134e23f6b1243215cd39346d0111d28600ca295849e16b4048fc708cc1d3b842ce7f40438a
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 forward_remote_port_to_local(remote_port, local_port)
55
- Chef::Log.debug("Forwarding container port #{remote_port} to local port #{local_port}")
56
- # Create the channel that will let the container and the host talk to each other
57
- channel = LXC::Extra::Channel.new
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
- # Start the container side of the proxy, listening for client connections
60
- pid = container.attach do
61
- begin
62
- server = TCPServer.new('127.0.0.1', remote_port)
63
- proxy = LXC::Extra::ProxyClientSide.new(channel, server)
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
- # Start the host side of the proxy, which contacts the real server
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
- @port_forwards << [ pid, thread, channel ]
87
+ end
88
+ local_url
80
89
  end
81
90
 
82
91
  def read_file(path)
@@ -1,3 +1,3 @@
1
1
  module ChefMetalLXC
2
- VERSION = '0.2'
2
+ VERSION = '0.3'
3
3
  end
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.2'
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-04 00:00:00.000000000 Z
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef